[Super-tux-commit] supertux/src gameloop.cpp,1.169,1.170
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-09-13 12:08:57
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5192/src Modified Files: gameloop.cpp Log Message: Moved cheating code, so that it ain't run every cycle, but only when a new key is pressed. last_keys.clear() shouldn't be needed and would shrink code a lot, but might be better to leave it. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.169 retrieving revision 1.170 diff -u -d -r1.169 -r1.170 --- gameloop.cpp 12 Sep 2004 16:11:49 -0000 1.169 +++ gameloop.cpp 13 Sep 2004 12:08:40 -0000 1.170 @@ -385,6 +385,41 @@ ch[1] = '\0'; } last_keys.append(ch); // add to cheat keys + + // Cheating words (the goal of this is really for debugging, + // but could be used for some cheating, nothing wrong with that) + if(compare_last(last_keys, "grow")) + { + tux.grow(false); + last_keys.clear(); + } + if(compare_last(last_keys, "fire")) + { + tux.grow(false); + tux.got_power = tux.FIRE_POWER; + last_keys.clear(); + } + if(compare_last(last_keys, "ice")) + { + tux.grow(false); + tux.got_power = tux.ICE_POWER; + last_keys.clear(); + } + if(compare_last(last_keys, "lifeup")) + { + player_status.lives++; + last_keys.clear(); + } + if(compare_last(last_keys, "lifedown")) + { + player_status.lives--; + last_keys.clear(); + } + if(compare_last(last_keys, "invincible")) + { // be invincle for the rest of the level + tux.invincible_timer.start(time_left.get_left()); + last_keys.clear(); + } break; } } @@ -462,46 +497,6 @@ } } /* while */ } - -// Cheating words (the goal of this is really for debugging, but could -// be used for some cheating) -// TODO: this could be implmented in a more elegant and faster way -if(!last_keys.empty()) - { - Player &tux = *currentsector->player; - if(compare_last(last_keys, "grow")) - { - tux.grow(false); - last_keys.clear(); - } - if(compare_last(last_keys, "fire")) - { - tux.grow(false); - tux.got_power = tux.FIRE_POWER; - last_keys.clear(); - } - if(compare_last(last_keys, "ice")) - { - tux.grow(false); - tux.got_power = tux.ICE_POWER; - last_keys.clear(); - } - if(compare_last(last_keys, "lifeup")) - { - player_status.lives++; - last_keys.clear(); - } - if(compare_last(last_keys, "lifedown")) - { - player_status.lives--; - last_keys.clear(); - } - if(compare_last(last_keys, "invincible")) - { // be invincle for the rest of the level - tux.invincible_timer.start(time_left.get_left()); - last_keys.clear(); - } - } } void |