From 57ee5f87376ff34ea01d43d329d9893778ee7ff8 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Mon, 13 Sep 2004 12:08:40 +0000 Subject: [PATCH] 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 --- src/gameloop.cpp | 75 ++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 40 deletions(-) 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 -- 2.11.0