+ case SDL_KEYDOWN: /* A keypress! */
+ {
+ SDLKey key = event.key.keysym.sym;
+
+ if(tux.key_event(key,DOWN))
+ break;
+
+ switch(key)
+ {
+ case SDLK_ESCAPE: /* Escape: Open/Close the menu: */
+ on_escape_press();
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ case SDL_KEYUP: /* A keyrelease! */
+ {
+ SDLKey key = event.key.keysym.sym;
+
+ if(tux.key_event(key, UP))
+ break;
+
+ switch(key)
+ {
+ case SDLK_a:
+ if(debug_mode)
+ {
+ char buf[160];
+ snprintf(buf, sizeof(buf), "P: %4.1f,%4.1f",
+ tux.get_pos().x, tux.get_pos().y);
+ context->draw_text(white_text, buf,
+ Vector(0, screen->h - white_text->get_height()),
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
+ context->do_drawing();
+ SDL_Delay(1000);
+ }
+ break;
+ case SDLK_p:
+ if(!Menu::current())
+ {
+ // "lifeup" cheat activates pause cause of the 'p'
+ // so work around to ignore it
+ if(compare_last(last_keys, "lifeu"))
+ break;
+
+ if(game_pause)
+ {
+ game_pause = false;
+ Ticks::pause_stop();
+ }
+ else
+ {
+ game_pause = true;
+ Ticks::pause_start();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ /* Check if chacrater is ASCII */
+ char ch[2];
+ if((event.key.keysym.unicode & 0xFF80) == 0)
+ {
+ ch[0] = event.key.keysym.unicode & 0x7F;
+ 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, "grease"))
+ {
+ tux.physic.set_velocity_x(tux.physic.get_velocity_x()*3);
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "invincible"))
+ { // be invincle for the rest of the level
+ tux.invincible_timer.start(10000);
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "shrink"))
+ { // remove powerups
+ tux.kill(tux.SHRINK);
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "kill"))
+ { // kill Tux, but without losing a life
+ player_status.lives++;
+ tux.kill(tux.KILL);
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "grid"))
+ { // toggle debug grid
+ debug_grid = !debug_grid;
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "hover"))
+ { // toggle hover ability on/off
+ tux.enable_hover = !tux.enable_hover;
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "gotoend"))
+ { // goes to the end of the level
+ tux.move(Vector(
+ (currentsector->solids->get_width()*32)
+ - (screen->w*2),
+ 0));
+ currentsector->camera->reset(
+ Vector(tux.get_pos().x, tux.get_pos().y));
+ last_keys.clear();
+ }
+ // temporary to help player's choosing a flapping
+ if(compare_last(last_keys, "marek"))
+ {
+ tux.flapping_mode = Player::MAREK_FLAP;
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "ricardo"))
+ {
+ tux.flapping_mode = Player::RICARDO_FLAP;
+ last_keys.clear();
+ }
+ if(compare_last(last_keys, "ryan"))
+ {
+ tux.flapping_mode = Player::RYAN_FLAP;
+ last_keys.clear();
+ }
+ break;