Ejemplo n.º 1
0
void	click_re_match(t_data *data, t_window *w)
{
  w->continuer = 1;
  while (w->continuer)
    {
      SDL_WaitEvent(&w->event);
      switch(w->event.type)
	{
	case SDL_QUIT:
	  quit_game(w);
	case SDL_KEYDOWN:
	  key_pressed(data, w);
	case SDL_MOUSEBUTTONUP:
	  w->x = w->event.button.x;
	  w->continuer = 0;
	case SDL_MOUSEMOTION:
	  SDL_BlitSurface(w->background_r, NULL, w->ecran, &w->pos_background_c);
	  w->pos_cursor.x = w->event.motion.x - 128;
	  w->pos_cursor.y = w->event.motion.y - 64;
	  SDL_BlitSurface(w->cursor, NULL, w->ecran, &w->pos_cursor);
	  SDL_Flip(w->ecran);
	  break;
	}
    }
  if_click_re_match(data, w);
}
Ejemplo n.º 2
0
void	win_check(t_data *data)
{
	t_tlist		*team;
	t_plist		*list;
	int			count;

	team = data->teams;
	while (team)
	{
		count = 0;
		list = team->list;
		while (list)
		{
			if (list->player->level == 8)
				count++;
			list = list->next;
		}
		if (count >= 6)
		{
			gui_broadcast(data, gui_seg, team);
			quit_game(data);
		}
		team = team->next;
	}
}
Ejemplo n.º 3
0
void	my_color(t_loop *loop)
{
  if (has_colors() == TRUE)
    start_color();
  else
    quit_game(loop);
}
Ejemplo n.º 4
0
int	poirier_main(t_loop *data, int size)
{
  if ((size = read(0, data->buff, data->ini.max)) < 0)
    quit_game(data);
  data->buff[size] = '\0';
  if (data->pause == 0)
    data->timer = data->timer + 2 *
      (data->ini.game.level > 13 ? (13) : (data->ini.game.level));
  if (size > 0)
    {
      if (check_move(data->buff, data, data->ptr))
	init_new_form(data, 1);
      if (my_view(data))
	quit_game(data);
    }
  return (0);
}
Ejemplo n.º 5
0
int	init_main_loop(t_loop *data)
{
  if (data->map_error == 1)
    {
      my_putsterr("Resize your terminal!\n");
      quit_game(data);
    }
  if (nb_form_werror(data) == 0)
    return (1);
  if (init_first_tetri(data))
    return (1);
  if ((data->buff = malloc(sizeof(char) * (data->ini.max + 1))) == NULL)
    return (my_putsterr("Malloc failed\n"));
  if (my_set_term(data, 0) == -1)
    return (1);
  return (0);
}
Ejemplo n.º 6
0
void
process_display_events (void)
{
  ALLEGRO_EVENT event;
  while (al_get_next_event (event_queue, &event))
    switch (event.type) {
    case ALLEGRO_EVENT_DISPLAY_EXPOSE:
      show ();
      break;
    case ALLEGRO_EVENT_DISPLAY_RESIZE:
      acknowledge_resize ();
      show ();
      break;
    case ALLEGRO_EVENT_DISPLAY_CLOSE:
      quit_game ();
      break;
    }
}
Ejemplo n.º 7
0
/*	title_key_hit handles key events for the demo and title screen
*/
void	title_key_hit(XKeyEvent *event)
{
	char			buf;
	KeySym			key;
	XComposeStatus	i;
	int				length;
	
	length = XLookupString(event, &buf, 1, &key, &i);
	switch(key) {
		case 'Q':
		case 'q':
			quit_game();
			break;
		default:
			if(length > 0) {
				gameover = 0;
				leveldone = 1;
			}
	}
}
Ejemplo n.º 8
0
/**************************
** prints the main menue **
**************************/
int menue(struct gamehandle *myrill)
{
    int input, again = 1;
    erase();
    printw("(N)ew Game\n");
    printw("(L)oad Game\n");
    printw("(H)elp\n");
    printw("(Q)uit\n");
    printw("What do you want to do?");
    refresh();
    while (again) {
        input = getch();
        switch (input) {
        case 'n':
        case 'N':
            again = 0;
            return (1);
            break;
        case 'l':
        case 'L':
            again = 0;
            return (2);
            break;
        case 'h':
        case 'H':
            again = 0;
            return (3);
            break;
        case 'q':
        case 'Q':
            again = 0;
            quit_game(myrill);
            break;
        default:
            continue;
        }
    }
    return (0);
}
Ejemplo n.º 9
0
/**
 * quit_cb
 * @action: Pointer to action
 * @data: Callback data
 *
 * Description:
 * Callback for exit menu entry
 *
 * Returns:
 **/
void
quit_cb (GtkAction * action, gpointer data)
{
  quit_game ();
}