diff --git a/asteroids/AsteroidEntity.cc b/asteroids/AsteroidEntity.cc index aa923a3..09937ad 100644 --- a/asteroids/AsteroidEntity.cc +++ b/asteroids/AsteroidEntity.cc @@ -14,13 +14,11 @@ namespace asteroids { bool AsteroidEntity::CollisionEvent (Engine::EntityBase* entity_state) { GameEntityType other_type = (GameEntityType) entity_state->mType; - Engine::LogDebug ("CONTACT OF AN ASTEROID"); - if (other_type == GameEntityTypeRocket) { // First remove the rocket Engine::KillEntity (entity_state->mId); - Engine::LogMessage ("You killed an ASTEROID!"); + Engine::LogMessage ("You killed an Asteroid!"); int i; for (i = 0; i < mSubAsteroidsCount; i++) { diff --git a/asteroids/Controller.h b/asteroids/Controller.h index f81881b..d44c879 100644 --- a/asteroids/Controller.h +++ b/asteroids/Controller.h @@ -13,9 +13,6 @@ namespace asteroids { */ enum EntityControllerKeyState { EntityKeyStateForward = 0, - EntityKeyStateBack, - EntityKeyStateLeft, - EntityKeyStateRight, EntityKeyStateTurnLeft, EntityKeyStateTurnRight, EntityKeyStateLast diff --git a/asteroids/ControllerCommands.cc b/asteroids/ControllerCommands.cc index 01464bd..bcb42c3 100644 --- a/asteroids/ControllerCommands.cc +++ b/asteroids/ControllerCommands.cc @@ -50,84 +50,6 @@ bool Cmd_ControllerForwardUp (std::vector args) { return false; } -/* +back */ -bool Cmd_ControllerBackDown (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->SetControllerKeyState (EntityKeyStateBack); - return true; - } - - return false; -} - -/* -back */ -bool Cmd_ControllerBackUp (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->UnsetControllerKeyState (EntityKeyStateBack); - return true; - } - - return false; -} - -/* +left */ -bool Cmd_ControllerLeftDown (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->SetControllerKeyState (EntityKeyStateLeft); - return true; - } - - return false; -} - -/* -left */ -bool Cmd_ControllerLeftUp (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->UnsetControllerKeyState (EntityKeyStateLeft); - return true; - } - - return false; -} - -/* +right */ -bool Cmd_ControllerRightDown (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->SetControllerKeyState (EntityKeyStateRight); - return true; - } - - return false; -} - -/* -right */ -bool Cmd_ControllerRightUp (std::vector args) { - assert (ControllerInstance); - - Engine::EntityBase* player_entity = Engine::GetEntity (Engine::GetPlayerEntityId()); - if (player_entity) { - player_entity->UnsetControllerKeyState (EntityKeyStateRight); - return true; - } - - return false; -} - /* +turnleft */ bool Cmd_ControllerTurnLeftDown (std::vector args) { assert (ControllerInstance); @@ -198,13 +120,6 @@ void Controller::OnRegisterCommands () { Engine::AddCommand ("+forward", Cmd_ControllerForwardDown); Engine::AddCommand ("-forward", Cmd_ControllerForwardUp); - Engine::AddCommand ("+back", Cmd_ControllerBackDown); - Engine::AddCommand ("-back", Cmd_ControllerBackUp); - - Engine::AddCommand ("+left", Cmd_ControllerLeftDown); - Engine::AddCommand ("-left", Cmd_ControllerLeftUp); - Engine::AddCommand ("+right", Cmd_ControllerRightDown); - Engine::AddCommand ("-right", Cmd_ControllerRightUp); Engine::AddCommand ("+turnleft", Cmd_ControllerTurnLeftDown); Engine::AddCommand ("-turnleft", Cmd_ControllerTurnLeftUp); diff --git a/asteroids/RocketEntity.h b/asteroids/RocketEntity.h index 4adcb76..00571a6 100644 --- a/asteroids/RocketEntity.h +++ b/asteroids/RocketEntity.h @@ -27,7 +27,6 @@ struct RocketEntity: public Engine::EntityBase { virtual void Update (float delta_sec); virtual bool CollisionEvent (Engine::EntityBase *entity) { - Engine::LogMessage ("Rocket BOOM"); return false; } diff --git a/asteroids/ShipEntity.cc b/asteroids/ShipEntity.cc index 9a4fc88..6490c76 100644 --- a/asteroids/ShipEntity.cc +++ b/asteroids/ShipEntity.cc @@ -125,7 +125,7 @@ void ShipEntity::Attack () { rocket_physics->mPosition += entity_physic->mPosition; rocket_physics->mOrientation = entity_physic->mOrientation; rocket_physics->mVelocity = attack_dir.normalize(); - rocket_physics->mVelocity *= ShipEntity::VarMaxSpeed.GetFloatValue() + 0.1; + rocket_physics->mVelocity *= ShipEntity::VarMaxSpeed.GetFloatValue() + 0.5; } } diff --git a/asteroids/main.cc b/asteroids/main.cc index fb941b3..3515097 100644 --- a/asteroids/main.cc +++ b/asteroids/main.cc @@ -22,15 +22,24 @@ int main (int argc, char* argv[]) { engine.SetPhysics (new asteroids::Physics); engine.SetView (new asteroids::View); - SetLogPrintLevel (Engine::LogLevelDebug); + SetLogPrintLevel (Engine::LogLevelMessage); Engine::SetLogFilename ("game.log"); if (engine.Init (argc, argv) != 0) { cout << "Could not start engine!" << endl; exit (-1); } - - SDL_WM_SetCaption("Asteroids -TechDemo- 10.04","Asteroids"); + + // Load the icon + Uint32 colorkey; + SDL_Surface *image = NULL; + image = SDL_LoadBMP("./data/textures/icon.bmp"); + if (!image) + Engine::LogWarning("Could not load icon: ./data/textures/icon.bmp"); + else + SDL_WM_SetIcon(image,NULL); + + SDL_WM_SetCaption("Asteroids -Leaked TechDemo-","Asteroids -Leaked TechDemo-"); engine.GetView()->SetGridSize (8,8); dynamic_cast(engine.GetPhysics())->SetWorldSize (28, 20); @@ -39,6 +48,9 @@ int main (int argc, char* argv[]) { engine.MainLoop (); + SDL_WM_SetIcon(NULL,NULL); + SDL_FreeSurface (image); + engine.Destroy (); cout << "Game Quit" << endl; diff --git a/data/textures/icon.bmp b/data/textures/icon.bmp new file mode 100644 index 0000000..0d6e504 Binary files /dev/null and b/data/textures/icon.bmp differ diff --git a/engine/Engine.cc b/engine/Engine.cc index ead5d74..4a155db 100644 --- a/engine/Engine.cc +++ b/engine/Engine.cc @@ -73,6 +73,7 @@ int Engine::OnInit (int argc, char* argv[]) { LogError ("Error initializing SDL: %s", SDL_GetError ()); exit (-1); } + SDL_WM_SetCaption("Engine Initializing","Engine Initializing"); /* Model */ if (mModel == NULL) diff --git a/engine/Logging.cc b/engine/Logging.cc index 23ca1fa..d538a32 100644 --- a/engine/Logging.cc +++ b/engine/Logging.cc @@ -40,9 +40,6 @@ void Logging::OnDestroy () { * Module specific functions */ void Logging::Log (LogLevel level, const char *str, ...) { - if (level < mPrintLevel) - return; - static char msg[LOG_MAX_MESSAGE_LENGTH]; static int last_length = LOG_MAX_MESSAGE_LENGTH; static int i; @@ -58,12 +55,15 @@ void Logging::Log (LogLevel level, const char *str, ...) { last_length = strlen (msg); assert (last_length < LOG_MAX_MESSAGE_LENGTH); - std::cout << msg << std::endl; + if (level >= mPrintLevel) + std::cout << msg << std::endl; LogEntry log_entry (level, msg); mLogEntries.push_back (log_entry); + // write the logs to file if (mLogFileOut) { + /// \TODO also write out the log level time_t timer = time(NULL); std::string timestr (asctime(localtime(&timer))); mLogFileOut << timestr.substr(0, timestr.size() - 1) << ' ' << msg << std::endl; diff --git a/engine/Logging.h b/engine/Logging.h index d029837..7804dc7 100644 --- a/engine/Logging.h +++ b/engine/Logging.h @@ -7,6 +7,12 @@ namespace Engine { class Module; /** \brief All logging goes through this class + * + * Only log messages higher or equal that of mPrintLevel are printed out. When + * a log filename was specified by Logging::SetLogFilename() then all messages + * sent to the Logging class are written to the file. + * + * \TODO Add log level for files separately */ class Logging : public Module { public: