Exemplo n.º 1
0
int	operate_event(SDL_Surface *screen
		      , SDL_Surface *arena, SDL_Rect *pos, SDL_Rect *dim)
{
  static Uint32	a_time = 0;
  Uint32	n_time;
  SDL_Event	event;

  if (a_time == 0)
    a_time = SDL_GetTicks();
  n_time = SDL_GetTicks();
  while (n_time - a_time <= 1000)
    if (SDL_PollEvent(&event) == 0)
      n_time = SDL_GetTicks();
    else if (event.key.keysym.sym == SDLK_ESCAPE)
      return (1);
    else if (event.key.keysym.sym == SDLK_DOWN)
      my_down(screen, arena, pos, dim);
    else if (event.key.keysym.sym == SDLK_UP)
      my_up(screen, arena, pos);
    else if (event.key.keysym.sym == SDLK_RIGHT)
      my_right(screen, arena, pos, dim);
    else if (event.key.keysym.sym == SDLK_LEFT)
      my_left(screen, arena, pos);
    else
      n_time = SDL_GetTicks();
  a_time = SDL_GetTicks();
  return (0);
}
Exemplo n.º 2
0
void			my_next(t_tools tool, t_list **list, int buff)
{
  struct winsize        argp;
  struct termios	tmp;

  tmp.c_iflag = 0;
  if (ioctl (0, TIOCGWINSZ, &argp) == -1)
    {
      my_restore(tool, tmp);
      my_errors("Ioctl : error\n", NULL);
    }
  my_left(tool, list, buff, argp);
  my_right(tool, list, buff, argp);
}