예제 #1
0
파일: interface.c 프로젝트: wader/gtktetris
void game_start_stop(GtkMenuItem     *widget,
		     gpointer user_data)
{
  game_play=!game_play;
  gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
  if(game_play)
    {
      gtk_widget_set_sensitive(menu_game_stop,TRUE);
      gtk_widget_set_sensitive(menu_game_quick,FALSE);
      gtk_widget_set_sensitive(menu_game_start,FALSE);
      gtk_widget_set_sensitive(Start_stop_button,TRUE);
      gtk_label_set(GTK_LABEL(Start_stop_button_label),start_stop_str[1]);
      gtk_widget_set_sensitive(Pause_button,TRUE);
      gtk_widget_grab_default(Pause_button);
      game_init();
      make_noise(options.noise_l,options.noise_h);
      from_virtual();
      move_block(0,0,0);
      current_level = options.level;
      update_game_values(0,current_level,0);
      timer = gtk_timeout_add(level_speeds[current_level],(GtkFunction)game_loop,NULL);
    }
  else
    game_over_init();
}
예제 #2
0
파일: main.c 프로젝트: h4xxel/birdie26
int main(int argc, char  **argv) {
	char font_path[512];
	char *tmp;
	bool fullscreen = false;
	
	if (argc >= 2 && !strcmp(argv[1], "-fs"))
		fullscreen = true;
		

	d_init_custom("Fascister i grönsakslandet ~ //achtung fulkod", DISPLAY_WIDTH, DISPLAY_HEIGHT, fullscreen, "birdie26", NULL);
	
	sprintf(font_path, "%s", d_fs_exec_path());
	chdir(tmp = dirname(font_path));
	sprintf(font_path, "%s/res/font.ttf", tmp);
	gfx.font.large = d_font_load(font_path, 36, 256, 256);
	gfx.font.small = d_font_load(font_path, 16, 256, 256);
	s = malloc(sizeof(*s));

	ui_init(4);
	menu_init();
	gameroom_init();
	lobby_init();
	character_room_init();
	game_over_init();
	
	gamestate_pane[GAME_STATE_MENU] = &menu.pane;
	gamestate_pane[GAME_STATE_SELECT_NAME] = &select_name.pane;
	gamestate_pane[GAME_STATE_CHARACTERS] = &character_room.pane;
	gamestate_pane[GAME_STATE_LOBBY] = &lobby.pane;
	gamestate_pane[GAME_STATE_ENTER_IP] = &enter_ip.pane;
	gamestate_pane[GAME_STATE_GAMEROOM] = &gameroom.pane;
	gamestate_pane[GAME_STATE_GAME_OVER] = &game_over.pane;
	
	
	signal(SIGINT, d_quit); //lol
	network_init(PORT);
	
	d_cursor_show(1);
	d_render_clearcolor_set(0x7F, 0x7F, 0x7F);
	
	if(argc > 1) {
		snprintf(player_name, NAME_LEN_MAX, "%s", argv[1]);
		game_state(GAME_STATE_MENU);
	} else
		game_state(GAME_STATE_SELECT_NAME);
	while(gamestate!=GAME_STATE_QUIT) {
		if(state_network_handler[gamestate])
			state_network_handler[gamestate]();
		
		d_render_begin();
		d_render_blend_enable();
		
		d_render_tint(20, 20, 20, 255);
		
		if(gamestate_pane[gamestate])
			ui_events(gamestate_pane[gamestate], 1);
	
		d_render_tint(255, 255, 255, 255);
		if(state_render[gamestate])
			state_render[gamestate]();
		
		if(state_network_handler[gamestate])
			state_network_handler[gamestate]();
	
		d_render_end();
		d_loop();
	}

	d_quit();
	return 0;
}