Exemplo n.º 1
0
static void init() {
	d_init_custom("svgestim", 800, 480, 0, "svgestim", NULL);
	platform=d_platform_get();
	
	font.univox=d_font_load("univox.ttf", 32, 512, 512);
	font.vectroid=d_font_load("vectroid.ttf", 32, 512, 512);
	
	highscore_init();
	menu_init();
	game_init();
	//pause_init();
	map_init();
	
	d_render_blend_enable();
}
Exemplo n.º 2
0
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.
}
Exemplo n.º 3
0
static void init() {
	int i;
	DARNIT_INPUT_MAP map;

	d_init("pewpewtris", "pewpewtris", NULL);
	d_fs_mount_self();
	d_fs_mount("music.ldi");
	d_fs_mount("sounds.ldi");
	config_init();
	
	ppt.ui.offset_x = 288;
	ppt.ui.offset_y = 0;

	for (i = 0; i < 180; ppt.tile_lookup[i++] = -1);

	ppt.block = d_render_tilesheet_load("res/block.png", 24, 24, DARNIT_PFORMAT_RGB5A1);
	ppt.tile = d_render_tile_new(10 * 18, ppt.block);
	ppt.bbox = d_bbox_new(180);
	d_bbox_set_indexkey(ppt.bbox);
	ppt.tm = d_tilemap_new(0xFFF, ppt.block, 0xFFF, 10, 18);
	ppt.request_new = 0;
	ppt.font = d_font_load("res/font.ttf", 28, 256, 256);
	ui_init();
	bullet_init(30);
	highscore_init();
	state_init();
	music_init();
	
	ppt.ui.play_background = d_map_load("res/playfield_background.ldmz");
	ppt.ui.menu_background = d_map_load("res/mainmenu_background.ldmz");
	ppt.ui.highscore_background = d_map_load("res/highscore_background.ldmz");

	/* Re-map B to space */
	if (!(d_platform_get().platform & DARNIT_PLATFORM_PANDORA)) {
		map = d_keymapping_get();
		map.b = TPW_KEY_SPACE;
		d_keymapping_set(map);
	}

	block_particle_init();

	/* FIXME: Remove */
	ppt.fps = d_text_surface_new(ppt.font, 6, 1000, 0, 0);
}
Exemplo n.º 4
0
void view_init() {
	sidebar_width=platform_lowres?3*SIDEBAR_WIDTH_MAX/4:SIDEBAR_WIDTH_MAX;
	font_std=d_font_load("res/FreeMonoBold.ttf", platform_lowres?8:12, 512, 512);
	mouse_tilesheet=d_render_tilesheet_load("res/mouse.png", 16, 16, DARNIT_PFORMAT_RGB5A1);
	mouse_target_tilesheet=d_render_tilesheet_load("res/target.png", 32, 32, DARNIT_PFORMAT_RGB5A1);
	
	//Menu background
	int scale=config.plasma==0?1:(1<<(5-config.plasma));
	view_background_w=platform.screen_w/scale;
	view_background_h=platform.screen_h/scale;
	view_background_ts=d_render_tilesheet_new(1, 1, view_background_w, view_background_h, DARNIT_PFORMAT_RGB5A1);
	view_background_tile=d_render_tile_new(1, view_background_ts);
	view_background_pixbuf=malloc(view_background_w*view_background_h*sizeof(unsigned int));
	d_render_tilesheet_scale_algorithm(view_background_ts, DARNIT_SCALE_LINEAR);
	d_render_tile_move(view_background_tile, 0, 0, 0);
	d_render_tile_tilesheet_coord_set(view_background_tile, 0, 0, 0, view_background_w, view_background_h);
	d_render_tile_size_set(view_background_tile, 0, platform.screen_w, platform.screen_h);
	view_background_update(0);
	
	menu_init();
	lobby_init();
	game_view_init();
	gameover_init();
	chat_init();
	
	gamestate_pane[GAME_STATE_MENU]=&panelist_menu_sidebar;
	gamestate_pane[GAME_STATE_CREDITS]=&panelist_credits;
	gamestate_pane[GAME_STATE_CONNECTING]=&panelist_multiplayer_connecting;
	gamestate_pane[GAME_STATE_LOBBY]=&panelist_lobby_players;
	gamestate_pane[GAME_STATE_GAME]=&panelist_game_sidebar;
	gamestate_pane[GAME_STATE_GAME_MENU]=&panelist_game_menu;
	gamestate_pane[GAME_STATE_GAME_OVER]=&panelist_gameover_sidebar;
	gamestate_pane[GAME_STATE_QUIT]=NULL;
	
	map=NULL;
}
Exemplo n.º 5
0
int main(int argc, char **argv) {
	int i, j, js0_x, js0_y, js1_x, js1_y;
	void *font, *surface, *text, *mapsheet, *sprite, *textinput, *mtsprite, *fps_text, *tilebuf, *fancy_text;
	void *music;
	char test[256], fps[16];
	char *test_text;
	DARNIT_MOUSE mouse;
	DARNIT_KEYS keys;
	DARNIT_MAP *map;
	DARNIT_SPRITE *mapsprite;

	if (!d_init("TESTAPP - libDarnit", "testapp", NULL))
		return -1;

	compression_test();

	/* Sound/music */
	music = d_sound_tracked_load("latyl-greasy_duck_v1.mod", DARNIT_AUDIO_STREAM, DARNIT_AUDIO_STEREO);
	d_sound_play(music, 0, 127, 127, 0);

	/* Text rendering */
	test_text = malloc(64);
	font = d_font_load("dejavu_sans.ttf", 28, 512, 512);
	text = d_text_surface_new(font, 80, 800, 0, 460);
	fancy_text = d_text_surface_color_new(font, 16, 800, 0, 420);
	colorTest(fancy_text);
	fps_text = d_text_surface_new(font, 16, 200, 0, 40);


	/* Menutk test */
	surface = d_menu_vertical_new("Hello\nGoodbye\nOther\nNothing\nLess than nothing", 50, 100, font, 200, 10, 3);
	sprintf(test_text, "Héllo, world. Modify m€! Test of offsets");
	textinput = d_menu_textinput_new(0, 0, font, test_text, 64, 200);

	/* Sprites */
	sprite = d_sprite_load("test.spr", 0, DARNIT_PFORMAT_RGB5A1);
	mapsprite = d_sprite_load("baurn.spr", 0, DARNIT_PFORMAT_RGB5A1);
	d_sprite_move(sprite, 50, 50);
	d_sprite_move(mapsprite, 0, 0);
	d_sprite_animate_start(sprite);
	d_sprite_animate_start(mapsprite);
	
	mtsprite = d_mtsprite_load("testspr.mts");
	d_mtsprite_animate_start(mtsprite);

	/* Maps */

	mapsheet = d_render_tilesheet_load("mapsheet.png", 32, 32, DARNIT_PFORMAT_RGBA8);
	if ((map = d_map_load("testmap_iso.ldmz")) == NULL)
		fprintf(stderr, "Map load failed\n");
	d_tilemap_sprite_add(map->layer[0].tilemap, mapsprite);

	/* Tile caches */
	tilebuf = d_render_tile_new(1, mapsheet);
	d_render_tile_move(tilebuf, 0, 64, 64);
	d_render_tile_tilesheet_coord_set(tilebuf, 0, 16, 16, 32, 32);

	/* Misc */
	fprintf(stderr, "String lenght: %i\n", d_font_string_w(font, "ASDFÅÄÖ,,"));


	for (i = j = 0;;) {
		d_sprite_move(mapsprite, 64, j * 4);
		keys = d_keys_get();
		d_text_surface_reset(text); d_text_surface_reset(fps_text);
		mouse = d_mouse_get();
		d_joystick_get(&js0_x, &js0_y, &js1_x, &js1_y);
		sprintf(test, "X: %i, Y: %i, W: %i;; TX: %i, TY: %i;; nub0 (%i,%i) ;; nub1(%i,%i)", mouse.x, mouse.y, mouse.wheel, i*4, j*4, js0_x, js0_y, js1_x, js1_y);
		sprintf(fps, "%i", d_last_frame_time());
		d_text_surface_string_append(text, test);
		d_text_surface_string_append(fps_text, "ASDFÅÄÖ,,");

		if (keys.lmb)
			d_render_fade_in(1000, 1.0f, 0.0f, 0.0f);
		if (keys.rmb)
			d_render_fade_out(1000);

		d_render_begin();

		if (keys.left == 1)
			i--;
		if (keys.right == 1)
			i++;
		if (keys.up == 1)
			j--;
		if (keys.down == 1)
			j++;
		if (keys.select)
			fprintf(stderr, "Blololol\n");

		if (keys.r == 1)
			d_tilemap_camera_move(map->layer->tilemap, i*4, j*4);
		d_render_blend_enable();
		d_tilemap_draw(map->layer->tilemap);
		if (keys.l == 1)
			if (d_menu_loop(surface) != -1)
				return 0;
		d_menu_loop(textinput); 
		d_sprite_draw(sprite);
		d_text_surface_draw(text);
		d_text_surface_draw(fancy_text);
		d_text_surface_draw(fps_text);

		d_render_offset(-200, -200);
		d_mtsprite_draw(mtsprite);
		d_render_offset(0, 0);

		d_render_blend_disable();
		d_render_tile_draw(tilebuf, 1);
		d_render_end();
		d_loop();
	}


	return 0;
}
Exemplo n.º 6
0
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;
}