case JOY_X:
if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
{
- tux.input_.left = DOWN;
- tux.input_.right = UP;
+ tux.input.left = DOWN;
+ tux.input.right = UP;
}
else if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
{
- tux.input_.left = UP;
- tux.input_.right = DOWN;
+ tux.input.left = UP;
+ tux.input.right = DOWN;
}
else
{
- tux.input_.left = DOWN;
- tux.input_.right = DOWN;
+ tux.input.left = DOWN;
+ tux.input.right = DOWN;
}
break;
case JOY_Y:
if (event.jaxis.value > JOYSTICK_DEAD_ZONE)
- tux.input_.down = DOWN;
+ tux.input.down = DOWN;
else if (event.jaxis.value < -JOYSTICK_DEAD_ZONE)
- tux.input_.down = UP;
+ tux.input.down = UP;
else
- tux.input_.down = UP;
+ tux.input.down = UP;
/* Handle joystick for the menu */
if(show_menu)
{
- if(tux.input_.down == DOWN)
+ if(tux.input.down == DOWN)
menuaction = MENU_ACTION_DOWN;
else
menuaction = MENU_ACTION_UP;
break;
case SDL_JOYBUTTONDOWN:
if (event.jbutton.button == JOY_A)
- tux.input_.up = DOWN;
+ tux.input.up = DOWN;
else if (event.jbutton.button == JOY_B)
- tux.input_.fire = DOWN;
+ tux.input.fire = DOWN;
break;
case SDL_JOYBUTTONUP:
if (event.jbutton.button == JOY_A)
- tux.input_.up = UP;
+ tux.input.up = UP;
else if (event.jbutton.button == JOY_B)
- tux.input_.fire = UP;
+ tux.input.fire = UP;
if(show_menu)
menuaction = MENU_ACTION_HIT;
/* Handle events: */
- tux.input_.old_fire = tux.input_.fire;
+ tux.input.old_fire = tux.input.fire;
game_event();
score = 0;
distros = 0;
- player_input_init(&input_);
+ player_input_init(&input);
keymap.jump = SDLK_UP;
keymap.duck = SDLK_DOWN;
{
if(key == keymap.right)
{
- input_.right = state;
+ input.right = state;
return true;
}
else if(key == keymap.left)
{
- input_.left = state;
+ input.left = state;
return true;
}
else if(key == keymap.jump)
{
- input_.up = state;
+ input.up = state;
return true;
}
else if(key == keymap.duck)
{
- input_.down = state;
+ input.down = state;
return true;
}
else if(key == keymap.fire)
{
- input_.fire = state;
+ input.fire = state;
return true;
}
else
base.ym = 0;
old_base = base;
- player_input_init(&input_);
+ player_input_init(&input);
timer_init(&invincible_timer,true);
timer_init(&skidding_timer,true);
/* --- HANDLE TUX! --- */
- input();
+ handle_input();
/* Move tux: */
{
/* Facing the direction we're jumping? Go full-speed: */
- if (input_.fire == UP)
+ if (input.fire == UP)
{
base.xm = base.xm + ( newdir ? WALK_SPEED : -WALK_SPEED) * frame_ratio;
base.xm = -MAX_WALK_XM;
}
}
- else if ( input_.fire == DOWN)
+ else if ( input.fire == DOWN)
{
base.xm = base.xm + ( newdir ? RUN_SPEED : -RUN_SPEED) * frame_ratio;
void
Player::handle_vertical_input()
{
- if(input_.up == DOWN)
+ if(input.up == DOWN)
{
if (on_ground())
{
}
}
}
- else if(input_.up == UP && jumping)
+ else if(input.up == UP && jumping)
{
if (on_ground())
{
}
void
-Player::input()
+Player::handle_input()
{
/* Handle key and joystick state: */
-
if(duck == false)
{
- if (input_.right == DOWN && input_.left == UP)
+ if (input.right == DOWN && input.left == UP)
{
handle_horizontal_input(RIGHT);
}
- else if (input_.left == DOWN && input_.right == UP)
+ else if (input.left == DOWN && input.right == UP)
{
handle_horizontal_input(LEFT);
}
/* Jump/jumping? */
- if ( input_.up == DOWN || (input_.up == UP && jumping))
+ if ( input.up == DOWN || (input.up == UP && jumping))
{
handle_vertical_input();
}
/* Shoot! */
- if (input_.fire == DOWN && input_.old_fire == UP && got_coffee)
+ if (input.fire == DOWN && input.old_fire == UP && got_coffee)
{
add_bullet(base.x, base.y, base.xm, dir);
}
/* Duck! */
- if (input_.down == DOWN)
+ if (input.down == DOWN)
{
if (size == BIG && duck != true)
{
if(!timer_check(&frame_timer))
{
timer_start(&frame_timer,25);
- if (input_.right == UP && input_.left == UP)
+ if (input.right == UP && input.left == UP)
{
frame_main = 1;
frame_ = 1;
}
else
{
- if ((input_.fire == DOWN && (global_frame_counter % 2) == 0) ||
+ if ((input.fire == DOWN && (global_frame_counter % 2) == 0) ||
(global_frame_counter % 4) == 0)
frame_main = (frame_main + 1) % 4;
!timer_started(&safe_timer) &&
pbad_c->mode != HELD)
{
- if (pbad_c->mode == FLAT && input_.fire != DOWN)
+ if (pbad_c->mode == FLAT && input.fire != DOWN)
{
/* Kick: */
timer_start(&pbad_c->timer,5000);
}
- else if (pbad_c->mode == FLAT && input_.fire == DOWN)
+ else if (pbad_c->mode == FLAT && input.fire == DOWN)
{
pbad_c->mode = HELD;
pbad_c->base.y-=8;