+ /* 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;
+
+ case SDL_JOYAXISMOTION:
+ if (event.jaxis.axis == joystick_keymap.x_axis)
+ {
+ if (event.jaxis.value < -joystick_keymap.dead_zone)
+ {
+ tux.input.left = DOWN;
+ tux.input.right = UP;
+ }
+ else if (event.jaxis.value > joystick_keymap.dead_zone)
+ {
+ tux.input.left = UP;
+ tux.input.right = DOWN;
+ }
+ else
+ {
+ tux.input.left = DOWN;
+ tux.input.right = DOWN;
+ }
+ }
+ else if (event.jaxis.axis == joystick_keymap.y_axis)
+ {
+ if (event.jaxis.value > joystick_keymap.dead_zone)
+ {
+ tux.input.up = DOWN;
+ tux.input.down = UP;
+ }
+ else if (event.jaxis.value < -joystick_keymap.dead_zone)
+ {
+ tux.input.up = UP;
+ tux.input.down = DOWN;
+ }
+ else
+ {
+ tux.input.up = DOWN;
+ tux.input.down = DOWN;
+ }
+ }
+ break;
+
+ case SDL_JOYHATMOTION:
+ if(event.jhat.value & SDL_HAT_UP) {
+ tux.input.up = DOWN;
+ tux.input.down = UP;
+ } else if(event.jhat.value & SDL_HAT_DOWN) {
+ tux.input.up = UP;
+ tux.input.down = DOWN;
+ } else if(event.jhat.value & SDL_HAT_LEFT) {
+ tux.input.left = DOWN;
+ tux.input.right = UP;
+ } else if(event.jhat.value & SDL_HAT_RIGHT) {
+ tux.input.left = UP;
+ tux.input.right = DOWN;
+ } else if(event.jhat.value == SDL_HAT_CENTERED) {
+ tux.input.left = UP;
+ tux.input.right = UP;
+ tux.input.up = UP;
+ tux.input.down = UP;
+ }
+ break;
+
+ case SDL_JOYBUTTONDOWN:
+ if (event.jbutton.button == joystick_keymap.a_button)
+ tux.input.jump = DOWN;
+ else if (event.jbutton.button == joystick_keymap.b_button)
+ tux.input.fire = DOWN;
+ else if (event.jbutton.button == joystick_keymap.start_button)
+ on_escape_press();
+ break;
+ case SDL_JOYBUTTONUP:
+ if (event.jbutton.button == joystick_keymap.a_button)
+ tux.input.jump = UP;
+ else if (event.jbutton.button == joystick_keymap.b_button)
+ tux.input.fire = UP;
+ break;
+
+ default:
+ break;
+ } /* switch */