diff --git a/game/game.cpp b/game/game.cpp index b26bf61..4f05dd0 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -6,7 +6,7 @@ #include -//#define QUICK_TEST +#include "options.hpp" Game::Game() { @@ -19,49 +19,49 @@ Game::Game() // XXX // one dummy ship for testing -#ifdef QUICK_TEST - m_state->addPlayer(); -#endif + if (ISSET_FLAG(TEST_AUTORUN)) { + m_state->addPlayer(); + } } bool Game::cycle(float dt) { -#ifdef QUICK_TEST - // XXX the following is just testing code to do things + if (ISSET_FLAG(TEST_AUTORUN)) { + // XXX the following is just testing code to do things - static float total = 0.0; - static float acc = 0.0; + static float total = 0.0; + static float acc = 0.0; - //if (total == 0.0) { - // float speed = 0.005; - // m_state->players[0]->addCommand(new game::SetSpeedCommand(speed)); - // for (int i=0; i<100; i++) { - // float a = 2.0 * M_PI * util::randf_0_1(); - // m_state->players[0]->addCommand(new game::ShootCommand(a)); - // } - //} - - acc += dt; - total += dt; - - float spawnInterval = 0.1; - while (acc > spawnInterval) { - acc -= spawnInterval; - - float angle = 360.0 * util::randf_0_1(); - float speed = 0.01; - - m_state->players.back()->addCommand(new game::SetSpeedCommand(speed)); - m_state->players.back()->addCommand(new game::ShootCommand(angle)); - - //static bool done = false; - //if (total >= 10.0 && !done) { - // done = true; - - // m_state->players[0]->addCommand(new game::ClearTracesCommand()); + //if (total == 0.0) { + // float speed = 0.005; + // m_state->players[0]->addCommand(new game::SetSpeedCommand(speed)); + // for (int i=0; i<100; i++) { + // float a = 2.0 * M_PI * util::randf_0_1(); + // m_state->players[0]->addCommand(new game::ShootCommand(a)); + // } //} + + acc += dt; + total += dt; + + float spawnInterval = 0.1; + while (acc > spawnInterval) { + acc -= spawnInterval; + + float angle = 360.0 * util::randf_0_1(); + float speed = 0.01; + + m_state->players.back()->addCommand(new game::SetSpeedCommand(speed)); + m_state->players.back()->addCommand(new game::ShootCommand(angle)); + + //static bool done = false; + //if (total >= 10.0 && !done) { + // done = true; + + // m_state->players[0]->addCommand(new game::ClearTracesCommand()); + //} + } } -#endif // std::cout<<"adding dt: " << dt << std::endl; m_time_for_next_step += dt; diff --git a/game/main.cpp b/game/main.cpp index 707c21a..946b8e0 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -32,6 +32,7 @@ int main(int argc, char *argv[]) { // {"add", no_argument, 0, 'a'}, // {"append", no_argument, 0, 'b'}, // {"delete", required_argument, 0, 'd'}, + {"autorun", required_argument, 0, 'a'}, {"port", required_argument, 0, 'p'}, {"fps", no_argument, 0, 'f'}, {0, 0, 0, 0} @@ -40,7 +41,7 @@ int main(int argc, char *argv[]) { int option_index = 0; while(1){ - c = getopt_long (argc, argv, "p:f", + c = getopt_long (argc, argv, "p:fa", long_options, &option_index); if (c == -1) break; @@ -54,6 +55,9 @@ int main(int argc, char *argv[]) { strcpy(port,optarg); break; + case 'a': + SET_FLAG(TEST_AUTORUN, true); + break; case '?': /* getopt_long already printed an error message. */ diff --git a/game/options.hpp b/game/options.hpp index 920831a..f2271e1 100644 --- a/game/options.hpp +++ b/game/options.hpp @@ -1,8 +1,9 @@ #pragma once -#define TEST_FLAG1 0 -#define SHOW_FPS 1 -#define TEST_FLAG2 2 +#define TEST_FLAG1 0 +#define SHOW_FPS 1 +#define TEST_FLAG2 2 +#define TEST_AUTORUN 3 //...