diff --git a/asteroids/Controller.cc b/asteroids/Controller.cc index e98037c..14099a3 100644 --- a/asteroids/Controller.cc +++ b/asteroids/Controller.cc @@ -35,20 +35,19 @@ bool Controller::OnReceiveEvent (const Engine::EventBasePtr &event) { void Controller::ResetPlayerEntity () { Engine::HaltSoundLoop(Engine::GetResourceFullPath("/data/sounds/thrust.wav")); + // Reset the angular velocity of the player entity if one exists + if (GetModel()->GetPlayerEntityId() != Engine::NullEntityId) { + Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId()); + player_entity->mPhysicState->mAngleVelocity = 0.; + + int i; + for (i = 0; i < EntityControllerMaxKeyStates; i++) + player_entity->UnsetControllerKeyState(i); + + } + // We definitely have to reset the player entity id GetModel()->SetPlayerEntityId(Engine::NullEntityId); - - Engine::EntityBase *player_entity = GetModel()->GetEntity(GetModel()->GetPlayerEntityId()); - - // if we were unable to get the player then there is no need to invalidate - // the state - if (!player_entity) - return; - - int i; - for (i = 0; i < EntityControllerMaxKeyStates; i++) - player_entity->UnsetControllerKeyState(i); - } void Controller::ResetLevel() { diff --git a/asteroids/Model.cc b/asteroids/Model.cc index eb1df0c..f1e54f3 100644 --- a/asteroids/Model.cc +++ b/asteroids/Model.cc @@ -263,6 +263,8 @@ int Model::DoLoadLevel (const char* filename) { std::string entity_type_str; int entity_count = 0; + SetLevelTitle (""); + SetLevelAuthor (""); while (level_file >> entity_type_str) { if (entity_type_str[0] == '#') { diff --git a/asteroids/Model.h b/asteroids/Model.h index 5362bbb..d8dccaf 100644 --- a/asteroids/Model.h +++ b/asteroids/Model.h @@ -37,19 +37,19 @@ class Model : public Engine::ModelBase { std::string GetLevelName() { return mLevelName; }; void SetLevelName(const std::string &name) { - Engine::LogMessage("new level name: %s", name.c_str()); + Engine::LogDebug("new level name: %s", name.c_str()); mLevelName = name; } std::string GetLevelAuthor() { return mLevelAuthor; }; void SetLevelAuthor(const std::string &author) { - Engine::LogMessage("new level author: %s", author.c_str()); + Engine::LogDebug("new level author: %s", author.c_str()); mLevelAuthor = author; } std::string GetLevelTitle() { return mLevelTitle; }; void SetLevelTitle(const std::string &title) { - Engine::LogMessage("new level title: %s", title.c_str()); + Engine::LogDebug("new level title: %s", title.c_str()); mLevelTitle = title; } diff --git a/asteroids/ShipEntity.cc b/asteroids/ShipEntity.cc index 9725bc4..887f96e 100644 --- a/asteroids/ShipEntity.cc +++ b/asteroids/ShipEntity.cc @@ -107,7 +107,7 @@ void ShipEntity::Attack () { RocketEntity *rocket_entity = (RocketEntity*) Engine::CreateEntity (GameEntityTypeRocket); - rocket_entity->mSecToLive = 1.75; + rocket_entity->mSecToLive = 1.5; RocketEntityPhysicState *rocket_physics = (RocketEntityPhysicState*) rocket_entity->mPhysicState; rocket_physics->mPosition = attack_dir; diff --git a/asteroids/View.cc b/asteroids/View.cc index 07c68a2..0826b75 100644 --- a/asteroids/View.cc +++ b/asteroids/View.cc @@ -999,7 +999,7 @@ void View::DrawUiEditor() { GetModel()->SetLevelTitle(level_title); if (Engine::GUI::Button (55, "Save", 145, 380, button_width, button_height)) { - GetModel()->DoSaveLevel((level_name + std::string(".txt")).c_str()); + GetModel()->DoSaveLevel((level_name + std::string(".map")).c_str()); Engine::LogMessage ("Save"); mEditorState = EditorStateUnknown; } @@ -1021,9 +1021,9 @@ void View::DrawUiEditor() { if (Engine::GUI::LineEdit(52, 145, 210, level_name, 32)) GetModel()->SetLevelName(level_name); - if (Engine::FileExists (level_name + std::string(".txt"))) { + if (Engine::FileExists (level_name + std::string(".map"))) { if (Engine::GUI::Button (54, "Load", 145, 300, button_width, button_height)) { - GetModel()->DoLoadLevel((level_name + std::string(".txt")).c_str()); + GetModel()->DoLoadLevel((level_name + std::string(".map")).c_str()); Engine::LogMessage ("Load"); mEditorState = EditorStateUnknown; } diff --git a/asteroids/main.cc b/asteroids/main.cc index 1003ca3..c59486d 100644 --- a/asteroids/main.cc +++ b/asteroids/main.cc @@ -104,7 +104,10 @@ int main (int argc, char* argv[]) { HWND hWnd = GetConsoleWindow(); ShowWindow( hWnd, SW_HIDE ); #endif - + + create_dir ("./root"); + create_dir ("./root/blaa"); + Engine::Engine engine; engine.SetEntityFactory (new asteroids::EntityFactory); diff --git a/engine/PhysicsBase.cc b/engine/PhysicsBase.cc index cc489fb..6c3e7c3 100644 --- a/engine/PhysicsBase.cc +++ b/engine/PhysicsBase.cc @@ -107,12 +107,12 @@ int PhysicsBase::Simulate (float msec, ModelBase* model) { // collision_remaining_step -= 1.0e-4; } else { Move (info.time * (1 - alpha)); - LogDebug ("Resolving Step between %u and %u t = %f alpha = %f", entity_a_id, entity_b_id, info.time, alpha); - ResolveCollision (info.time * (1 - alpha), entity_a_id, entity_b_id, info); // Send the collision event to the Model (if we have one) if (model) { model->SendEntityCollisionEvent (entity_a_id, entity_b_id, info.time, info.point, info.normal); } + LogDebug ("Resolving Step between %u and %u t = %f alpha = %f", entity_a_id, entity_b_id, info.time, alpha); + ResolveCollision (info.time * (1 - alpha), entity_a_id, entity_b_id, info); collision_remaining_step -= info.time * (1 - alpha); }