예제 #1
0
파일: Robot.c 프로젝트: slaeshjag/kiruna
int main(int argc, char **argv) {

	d_init_custom("AutoKorg", WINDOW_WIDTH, WINDOW_HEIGHT, 0, "robot", NULL);
	//Calling an initiating function. Said function creates a window
	//with resolution 800x600, that's now full-screen and with the title AutoKorg.
	
	DARNIT_FONT *kgfont = d_font_load("KGRayofSunshine.ttf", 60, 256, 256);
	//We create a font handle.
	
	DARNIT_TEXT_SURFACE *papper = d_text_surface_new(kgfont, 100 , 800, 10, 0);
	//Here we create a handle to a text surface, using the font previously handled.
	
	/*pthread_t threads[1];
	hello = pthread_create(&threads[0], NULL, musikka, (void *) NULL);*/
	
	d_cursor_show(1); //Call a funciton which shows the cursor in the window.
	
	initiate_buttons();
	initiate_serial_port();
	
	for(;;) {
		
		//Program loop.
		
		d_render_begin(); 
		//Call to start rendering.
		
		d_render_blend_enable(); 
		//Enable blend, a call to a function apparently needed.
		
		if(state < DISCO){
			d_render_tint(255,255,255,255);
		} 
		else {
			d_render_tint(rand() & 0xF0, rand() & 0xF0, rand() & 0xF0, 255);
		}
		//Another call to a needed function. Don't question the libdarnit.
		
		//d_text_surface_string_append(papper, svar);
		
		do_stuff(papper); 
		//Call to a function which does stuff.
		
		draw_interface();
		//Draws us some graphics.
		
		d_render_end(); 
		//Call to a function which you do at the stop of rendering.
		
		d_loop(); 
		//Call to a function that is to be called inbetween frames.
		
		d_text_surface_reset(papper); 
		//Lastly we clear the textsurface.
	}
	return 0;

	//End of show.
}
예제 #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;
}