Exemplo n.º 1
0
int		exec_fct(SDL_Surface *screen, t_map *map)
{
  t_player	player;
  int		continuer;
  t_image	img;
  int		jump;
  t_npc		*monsters;

  SDL_EnableKeyRepeat(10, 10);
  continuer = 1;
  monsters = init_all(&img, &player, map);
  jump = 0;
  while (continuer > 0)
    {
      display_map(screen, map, &img);
      display_npcs(screen, monsters);
      display_player(screen, &player);
      display_life(screen, &player);
      SDL_Flip(screen);
      continuer = gravite(&player, map);
      if (continuer >= 0)
	player_act(&continuer, map, &player);
      if (continuer > 0)
	continuer = env_act(map, &player, monsters);
    }
  img_delete(&img);
  return (continuer);
}
Exemplo n.º 2
0
void update_player()
{
    switch(get_last_input()) {
        case INPUT_DIRECTIONAL:
            player_move(get_last_direction());
            break;
        case INPUT_ACTION:
            player_act();
            break;
    }
    if(hp_current < hp_max)
        hp_current++;
    if(hp_current > hp_max)
        hp_current = hp_max;
    if(ep_current > ep_max)
        ep_current = ep_max;
}