From: Ricardo Cruz Date: Mon, 13 Sep 2004 12:08:40 +0000 (+0000) Subject: Moved cheating code, so that it ain't run every cycle, but only when a new key is... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=57ee5f87376ff34ea01d43d329d9893778ee7ff8;p=supertux.git 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. SVN-Revision: 1899 --- diff --git a/src/gameloop.cpp b/src/gameloop.cpp index c36e9d4fe..5a85fa104 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -385,6 +385,41 @@ GameSession::process_events() 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 @@ GameSession::process_events() } } /* 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