if(show_menu)
menu_event(&event.key.keysym);
- if(player_keydown_event(&tux,key))
+ if(player_key_event(&tux,key,DOWN))
break;
switch(key)
case SDL_KEYUP: /* A keyrelease! */
key = event.key.keysym.sym;
- if(player_keyup_event(&tux,key))
+ if(player_key_event(&tux,key,UP))
break;
switch(key)
timer_init(&pplayer->safe_timer);
}
-int player_keydown_event(player_type* pplayer, SDLKey key)
+int player_key_event(player_type* pplayer, SDLKey key, int state)
{
if(key == pplayer->keymap.right)
{
- pplayer->input.right = DOWN;
+ pplayer->input.right = state;
return YES;
}
else if( key == pplayer->keymap.left)
{
- pplayer->input.left = DOWN;
+ pplayer->input.left = state;
return YES;
}
else if(key == pplayer->keymap.jump)
{
- pplayer->input.up = DOWN;
+ pplayer->input.up = state;
return YES;
}
else if(key == pplayer->keymap.duck)
{
- pplayer->input.down = DOWN;
+ pplayer->input.down = state;
return YES;
}
else if(key == pplayer->keymap.fire)
{
- pplayer->input.fire = DOWN;
- return YES;
- }
- else
- return NO;
-}
-
-int player_keyup_event(player_type* pplayer, SDLKey key)
-{
- if(key == pplayer->keymap.right)
- {
- pplayer->input.right = UP;
- return YES;
- }
- else if( key == pplayer->keymap.left)
- {
- pplayer->input.left = UP;
- return YES;
- }
- else if(key == pplayer->keymap.jump)
- {
- pplayer->input.up = UP;
- return YES;
- }
- else if(key == pplayer->keymap.duck)
- {
- pplayer->input.down = UP;
- return YES;
- }
- else if(key == pplayer->keymap.fire)
- {
- pplayer->input.fire = UP;
+ pplayer->input.fire = state;
return YES;
}
else
pplayer->input.old_fire = UP;
pplayer->input.right = UP;
pplayer->input.up = UP;
-
+
timer_init(&pplayer->invincible_timer);
timer_init(&pplayer->skidding_timer);
timer_init(&pplayer->safe_timer);
bigcape_right[2], bigcape_left[2];
void player_init(player_type* pplayer);
-int player_keydown_event(player_type* pplayer, SDLKey key);
-int player_keyup_event(player_type* pplayer, SDLKey key);
+int player_key_event(player_type* pplayer, SDLKey key, int state);
void player_level_begin(player_type* pplayer);
void player_action(player_type* pplayer);
void player_input(player_type* pplayer);