minor cleanups and added an icon

This commit is contained in:
2010-04-08 20:04:39 +02:00
parent 7c01aaf913
commit 60ee79152b
10 changed files with 28 additions and 100 deletions
+1 -3
View File
@@ -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++) {
-3
View File
@@ -13,9 +13,6 @@ namespace asteroids {
*/
enum EntityControllerKeyState {
EntityKeyStateForward = 0,
EntityKeyStateBack,
EntityKeyStateLeft,
EntityKeyStateRight,
EntityKeyStateTurnLeft,
EntityKeyStateTurnRight,
EntityKeyStateLast
-85
View File
@@ -50,84 +50,6 @@ bool Cmd_ControllerForwardUp (std::vector<std::string> args) {
return false;
}
/* +back */
bool Cmd_ControllerBackDown (std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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);
-1
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
}
+15 -3
View File
@@ -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<asteroids::Physics*>(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;