Ejemplo n.º 1
0
int		play(t_game *game)
{
  Uint8		*keys;
  int		key;
  char		finish;
  Uint32	timer, elapsed;

  finish = 1;
  music(game, "sprites/demacia.mp3");
  while (finish)
    {
      timer = SDL_GetTicks();
      SDL_FillRect(game->sdl.screen, NULL, 0);
      SDL_PumpEvents();
      keys = SDL_GetKeyState(&key);
      if (physics(&game->darien.darien, game) == 0)
	gere_key(game, &game->darien.darien.sprite, keys);
      aff_screen(game);
      elapsed = SDL_GetTicks() - timer;
      if (elapsed < 20)
	SDL_Delay(20 - elapsed);
      if (keys[SDLK_ESCAPE])
	finish = 0;
    }
  exit(0);
}
Ejemplo n.º 2
0
void		my_boucle(struct termios *t, t_list *list_final, t_node *node)
{
  char		buf[126];
  int		size;
  int		i;

  i = 0;
  while ((size = read(0, buf, 3)) != 0)
    {
      signal(SIGWINCH, &get_winsize);
      if (buf[0] == 27 && buf[1] == 91 && buf[2] == 66  \
	  && node->next && size == 3)
	node = down_key(node, &i);
      else if (buf[0] == 27 && buf[1] == 91 && buf[2] == 65     \
	       && node->prev && size == 3)
	node = up_key(node, &i);
      else if (buf[0] == 32 && size == 1)
	space_key(list_final, node);
      else if (buf[0] == 10 && size == 1)
	enter_key(t, list_final);
      else if (buf[0] == 27 && size == 1)
	echap_key(t);
      aff_screen(node, i);
    }
}