Ejemplo n.º 1
0
int main(int argc, char **argv) {
	char fps[6];
	init();

	d_tilemap_camera_move(ppt.tm, -ppt.ui.offset_x, -ppt.ui.offset_y);
	*fps = 0;

	for (;;) {
		d_render_begin();

		state_loop();

		/* FIXME: Remove */
		sprintf(fps, "%i", d_fps());
		d_text_surface_reset(ppt.fps);
		d_text_surface_string_append(ppt.fps, fps);
		d_render_blend_enable();
		d_text_surface_draw(ppt.fps);
		d_render_blend_disable();

		d_render_end();
		d_loop();
	}

	return 0;
}
Ejemplo n.º 2
0
void highscore_render() {
	char buff[2048];
	int i;
	
	d_text_surface_draw(highscore.title);
	d_text_surface_reset(highscore.text);

	for (i = 0; i < HIGHSCORE_CAP; i++) {
		if(!highscore_table[i].score)
			break;
		sprintf(buff, "%s", highscore_table[i].name);
		d_text_surface_string_append(highscore.text, buff);
		sprintf(buff, "%.8i\n", highscore_table[i].score);
		d_text_surface_offset_next_set(highscore.text, 500);
		d_text_surface_string_append(highscore.text, buff);
	}
	d_text_surface_draw(highscore.text);
	
	return;
}
Ejemplo n.º 3
0
void gameover_render() {
	static char scoretext[64];
	d_text_surface_draw(gameover.title);
	d_text_surface_draw(gameover.subtitle);
	d_text_surface_reset(gameover.score);
	sprintf(scoretext, "Score %i", score);
	d_text_surface_string_append(gameover.score, scoretext);
	if (highscore_is_new(score))
		d_text_surface_draw(highscore.enter_name);
	
	d_text_surface_draw(gameover.score);
}
Ejemplo n.º 4
0
void player_draw_stat() {
	char buff[32];

	sprintf(buff, "Score: %.8i\n", score);
	d_text_surface_reset(player->scoretext);
	d_text_surface_string_append(player->scoretext, buff);

	sprintf(buff, "Grenades: %.2i", player->grenades);
	d_text_surface_reset(player->grenadestext);
	d_text_surface_string_append(player->grenadestext, buff);

	d_render_rect_move(player->healthbar, 0, 0, 0, player->health * 2, PLAYER_HEALTH_BAR_HEIGHT);
	d_render_tint(255 - player->health * 255 / 100, player->health * 255 / 100, 0, 255);
	d_render_offset(0, 0);
	d_render_rect_draw(player->healthbar, 1);
	d_render_tint(255, 255, 255, 255);
	d_text_surface_draw(player->scoretext);
	d_text_surface_draw(player->grenadestext);

	return;
}
Ejemplo n.º 5
0
static void update_lists(struct List *player, struct List *game) {
	int i;
	
	d_text_surface_reset(lobby.list_players);
	d_text_surface_reset(lobby.list_games);
	
	d_text_surface_color_next(lobby.list_players, 255, 255, 255);
	d_text_surface_string_append(lobby.list_players, "Players in lobby\n\n");
	d_text_surface_color_next(lobby.list_games, 255, 255, 255);
	d_text_surface_string_append(lobby.list_games, "LAN Games\n\n");
	
	#if 0
	for(i = 0; i < players; i++) {
		/*if(i == lobby.selected_player) {
			d_text_surface_color_next(lobby.list_players, 255, 0, 0);
		} else {*/
			d_text_surface_color_next(lobby.list_players, 255, 255, 255);
		/*}*/
		d_text_surface_string_append(lobby.list_players, player[i]);
	}
	#endif
	
	for(i = 0; game; i++, game = game->next) {
		if(i == lobby.selected_game) {
			d_text_surface_color_next(lobby.list_games, 255, 0, 0);
		} else {
			d_text_surface_color_next(lobby.list_games, 255, 255, 255);
		}
		d_text_surface_string_append(lobby.list_games, ((struct LobbyHost *) (game->value))->name);
		if(i == 0)
			d_text_surface_string_append(lobby.list_games, "\n");
		else
			d_text_surface_string_append(lobby.list_games, "'s game\n");
	}
}
Ejemplo n.º 6
0
void lobby_init() {
	lobby.line = d_render_line_new(1, 2);
	d_render_line_move(lobby.line, 0, config.platform.screen_w - 320, 0, config.platform.screen_w - 320, config.platform.screen_h);
	
	lobby.list_players = d_text_surface_color_new(config.font_std, 2048, 300, 64, 0);
	lobby.list_games = d_text_surface_color_new(config.font_std, 2048, 300, config.platform.screen_w - 300, 0);
	
	lobby_join.list_players = d_text_surface_color_new(config.font_std, 2048, 300, 64, 0);
	lobby_host.start_game = d_text_surface_color_new(config.font_std, 32, 300, 64, config.platform.screen_h - 96);
	d_text_surface_color_next(lobby_host.start_game, 255, 0, 0);
	d_text_surface_string_append(lobby_host.start_game, "Press enter to start game");
	
	update_lists(NULL, lobby_client.client);
	
	lobby_playername.text_playername = d_text_surface_new(config.font_std, 64, 1024, 64, 64);
	lobby_playername.inputfield_playername = d_menu_textinput_new(64, 128, config.font_std, config.player_name, PROTO_PLAYER_NAME - 1, config.platform.screen_w);
	
	d_text_surface_string_append(lobby_playername.text_playername, "Enter your player name:");
	
	lobby.selected_game = 0;
	lobby.selected_player = 0;
}
Ejemplo n.º 7
0
int texteffect_add(const char *str, int time, int x, int y, int linel, unsigned r, unsigned g, unsigned b) {
	unsigned i;
	int j;

	if (ws.te.max_te == ws.te.te_used)
		texteffect_expand();
	for (i = 0; i < ws.te.max_te; i++) {
		if (ws.te.te[i].time_left)
			continue;
		else
			break;
	}

	j = 0;
	y -= d_font_string_geometrics_o(ws.te.font, str, linel, &j);
	ws.te.te[i].s = d_text_surface_color_new(ws.te.font, strlen(str), linel, x - (j >> 1), y);
	ws.te.te[i].time_left = time;
	ws.te.te[i].total_time = time;
	d_text_surface_color_next(ws.te.te[i].s, r, g, b);
	d_text_surface_string_append(ws.te.te[i].s, str);
	ws.te.te_used++;

	return i;
}
Ejemplo n.º 8
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;
}