Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18229/src
Modified Files:
gameloop.cpp gameloop.h
Log Message:
Implemented a cheating system, mainly for debugging.
It might be a bit ugly and could be faster. Feel free to replace it.
Cheat words are: grow, fire, ice, lifeup, lifedown, invincible.
Index: gameloop.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- gameloop.h 28 Jul 2004 23:06:12 -0000 1.57
+++ gameloop.h 11 Sep 2004 14:22:01 -0000 1.58
@@ -67,7 +67,6 @@
float fps_fps;
FrameRate frame_rate;
int pause_menu_frame;
- int debug_fps;
/** If true the end_sequence will be played, user input will be
ignored while doing that */
@@ -116,6 +115,9 @@
private:
static GameSession* current_;
+ // for cheating
+ std::string last_keys;
+
void restart_level();
void check_end_conditions();
@@ -127,7 +129,6 @@
void drawendscreen();
void drawresultscreen(void);
-private:
void on_escape_press();
void process_menu();
};
Index: gameloop.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -d -r1.166 -r1.167
--- gameloop.cpp 8 Sep 2004 17:32:31 -0000 1.166
+++ gameloop.cpp 11 Sep 2004 14:22:00 -0000 1.167
@@ -95,6 +95,8 @@
fps_timer.init(true);
frame_timer.init(true);
+ last_keys.clear();
+
#if 0
float old_x_pos = -1;
if (world)
@@ -361,42 +363,15 @@
}
}
break;
- case SDLK_TAB:
- if(debug_mode)
+ default:
+ /* Check if chacrater is ASCII */
+ char ch[2];
+ if((event.key.keysym.unicode & 0xFF80) == 0)
{
- tux.grow(false);
+ ch[0] = event.key.keysym.unicode & 0x7F;
+ ch[1] = '\0';
}
- break;
- case SDLK_END:
- if(debug_mode)
- player_status.distros += 50;
- break;
- case SDLK_DELETE:
- if(debug_mode)
- tux.got_power = tux.FIRE_POWER;
- break;
- case SDLK_HOME:
- if(debug_mode)
- tux.got_power = tux.ICE_POWER;
- break;
- case SDLK_INSERT:
- if(debug_mode)
- tux.invincible_timer.start(TUX_INVINCIBLE_TIME);
- break;
- case SDLK_l:
- if(debug_mode)
- --player_status.lives;
- break;
- case SDLK_s:
- if(debug_mode)
- player_status.score += 1000;
- case SDLK_f:
- if(debug_fps)
- debug_fps = false;
- else
- debug_fps = true;
- break;
- default:
+ last_keys.append(ch); // add to cheat keys
break;
}
}
@@ -474,6 +449,48 @@
}
} /* 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(last_keys.find("grow") != std::string::npos)
+ {
+ tux.grow(false);
+ last_keys.clear();
+ }
+ if(last_keys.find("fire") != std::string::npos)
+ {
+ tux.grow(false);
+ tux.got_power = tux.FIRE_POWER;
+ last_keys.clear();
+ }
+ if(last_keys.find("ice") != std::string::npos)
+ {
+ tux.grow(false);
+ tux.got_power = tux.ICE_POWER;
+ last_keys.clear();
+ }
+ if(last_keys.find("lifeup") != std::string::npos)
+ {
+ player_status.lives++;
+ last_keys.clear();
+ }
+ if(last_keys.find("lifedown") != std::string::npos)
+ {
+ player_status.lives--;
+ last_keys.clear();
+ }
+ if(last_keys.find("invincible") != std::string::npos)
+ { // be invincle for the rest of the level
+ tux.invincible_timer.start(time_left.get_left());
+ last_keys.clear();
+ }
+ if(last_keys.size() > 15)
+ last_keys.clear();
+ }
}
void
|