Esempio n. 1
0
void player_render() {
	if(!player)
		return;
	
	shapesprite_render(player->shape, player->x / 1000 - camera_x / 1000, player->y / 1000);
	
	//d_render_offset(-(800-256), -(480/2+30));
	//if(boss_shooting)
	//	shape_copy_render(flamethrower);
	
	d_render_offset(-(player->x / 1000 - camera_x / 1000)-4, -(player->y / 1000)+6);
	shape_copy_rotate(player->gun, player->gun_angle);
	shape_copy_render(player->gun);
	shape_copy_rotate(player->gun, -player->gun_angle);
	d_render_offset(-((player->x/1000) - camera_x/1000 )-16, -(player->y/1000+(player->gun_angle?player->gun_angle/20:0)));
	
	if(grenade_time) {
		d_render_tint(0x0, 0xFF, 0x0, 0xFF);
		shape_copy_render(player->grenade_shape);
		d_render_tint(0xFF, 0xFF, 0xFF, 0xFF);
	}
	d_render_offset(0, 0);
	if(gamestate_current()!=GAMESTATE_GAME)
		return;
	bullet_loop(&player->bullet);
	grenade_loop(&player->grenade);
	player_draw_stat();
	return;
}
Esempio n. 2
0
void lobby_loop() {
	static int tick = 0;
	DARNIT_KEYS keys;
	int i;
	struct List *game = lobby_client.client;
	
	d_render_tile_blit(config.menu_background, 0, 0, 0);
	d_render_line_draw(lobby.line, 1);
	d_text_surface_draw(lobby.list_players);
	
	if(lobby.selected_game > 5) {
		d_render_offset(0, (lobby.selected_game - 5) * d_font_glyph_hs(config.font_std));
	}
	d_text_surface_draw(lobby.list_games);
	d_render_offset(0, 0);
	
	keys = d_keys_get();
	d_keys_set(keys);
	
	if(!tick) {
		update_lists(NULL, lobby_client.client);
	}
	
	if(keys.up) {
		if(lobby.selected_game > 0)
			lobby.selected_game--;
	} else if(keys.down) {
		if(lobby.selected_game < lobby_client.clients)
			lobby.selected_game++;
	}
	
	if(keys.select) {
		game_state(GAME_STATE_MENU);
		return;
	}
	
	if(keys.start) {
		if(lobby.selected_game == 0) {
			game_state(GAME_STATE_LOBBY_HOST);
		} else {
			for(i = 0; game; i++, game = game->next) {
				if(i == lobby.selected_game) {
					config.server.addr = ((struct LobbyHost *) (game->value))->addr;
					goto join;
				}
			}
			game_state(GAME_STATE_LOBBY_HOST);
			return;
			join:
			game_state(GAME_STATE_LOBBY_JOIN);
		}
	}
	tick++;
	tick %= 3;
}
Esempio n. 3
0
void map_render() {
	int i;
	d_render_offset(camera_x / 1000, 0);
	for(i=0; i<map.sections; i++)
		d_render_line_draw(map.line[i], map.lines[i]);
	
	for(i=0; i<map.enemies; i++)
		enemy_render(map.enemy[i]);
	
	for(i=0; i<map.powerups; i++) {
		d_render_tint(powerup_color[map.powerup[i].type].r, powerup_color[map.powerup[i].type].g, powerup_color[map.powerup[i].type].b, 0xFF);
		if(!map.powerup[i].taken) {
			d_render_offset(-(map.powerup[i].x) + camera_x / 1000, -(map.powerup[i].y));
			shape_copy_render(map.powerup[i].shape);
		}
	}
	d_render_tint(0xFF, 0xFF, 0xFF, 0xFF);
	d_render_offset(0, 0);
}
Esempio n. 4
0
File: map.c Progetto: slaeshjag/Muon
void map_draw(int draw_powergrid) {
	int i;
	for(i=0; i<map->layers-2; i++)
		d_tilemap_draw(map->layer[i].tilemap);
	if(config.alpha)
		d_render_blend_enable();
	d_tilemap_draw(map->layer[map->layers-2].tilemap);
	d_render_blend_disable();
	//d_tilemap_draw(map->layer[map->layers-1].tilemap);
	
	d_render_offset(map->cam_x, map->cam_y);
	if(config.grid) {
		d_render_tint(18, 18, 18, 255);
		for(i=0; i<map_grid_chunks; i++)
			if(map_grid_chunk[i].lines&&map_grid_chunk[i].x+map_grid_chunk[i].w>map->cam_x&&map_grid_chunk[i].x<map->cam_x+platform.screen_w-sidebar_width&&map_grid_chunk[i].y+map_grid_chunk[i].h>map->cam_y&&map_grid_chunk[i].y<map->cam_y+platform.screen_h)
				d_render_line_draw(map_grid_chunk[i].lines, map_grid_chunk[i].size);
		d_render_tint(255, 255, 255, 255);
	}
	
	d_tilemap_draw(map->layer[map->layers-1].tilemap);
	
	if(powergrid&&(draw_powergrid||config.powergrid))
		d_render_line_draw(powergrid, powergrid_lines);
		
	map_flare_draw();
	
	if(map_selected.index>-1&&map_selected.building) {
		int x=map->layer[map->layers-2].tile_w*(map_selected.index%map->layer[map->layers-2].tilemap->w);
		int y=map->layer[map->layers-2].tile_h*(map_selected.index/map->layer[map->layers-2].tilemap->w);
		d_render_tint(player_color[map_selected.owner].r, player_color[map_selected.owner].g, player_color[map_selected.owner].b, 255);
		if(map_selected.circle)
			d_render_circle_draw(map_selected.circle);
		d_render_offset(map->cam_x-x, map->cam_y-y);
		d_render_line_draw(map_selected.border, 4);
	}
	d_render_tint(255, 255, 255, 255);
	d_render_offset(0, 0);
}
Esempio n. 5
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;
}
Esempio n. 6
0
void ambiance_draw() {
	int flicker_offset;

	if (ws.ambiance.flicker.flicker_interval) {
		if (ws.ambiance.flicker.flicker) {
			ws.ambiance.flicker.flicker += d_last_frame_time();
			flicker_offset = ws.ambiance.flicker.flicker;
			if (flicker_offset >= ws.ambiance.flicker.flicker_duration / 2)
				flicker_offset = ws.ambiance.flicker.flicker_duration / 2 - flicker_offset;
			flicker_offset *= ws.ambiance.flicker.flicker_offset;
			flicker_offset /= ws.ambiance.flicker.flicker_duration;
			ws.ambiance.flicker.flicker = flicker_offset;
		}
	}
	if (ws.ambiance.flicker.filter_active) {
		d_render_offset(0, 0);
		d_render_tint(ws.ambiance.flicker.r, ws.ambiance.flicker.g, ws.ambiance.flicker.b, ws.ambiance.flicker.a + ws.ambiance.flicker.flicker);
		d_render_rect_draw(ws.ambiance.flicker.rect, 1);
	}

	return;
}
Esempio n. 7
0
void stageSelectDraw() {
	DARNIT_KEYS keys;

	keys = d_keys_get();
	if (keys.left) {
		if ((--s->var.stage.selected_stage) < 0)
			s->var.stage.selected_stage = 8;
		d_keys_set(keys);
	} else if (keys.right) {
		if ((++s->var.stage.selected_stage) > 8)
			s->var.stage.selected_stage = 0;
		d_keys_set(keys);
	} else if (keys.up) {
		if ((s->var.stage.selected_stage -= 3) < 0)
			s->var.stage.selected_stage += 9;
		d_keys_set(keys);
	} else if (keys.down) {
		if ((s->var.stage.selected_stage += 3) > 8)
			s->var.stage.selected_stage -= 9;
		d_keys_set(keys);
	} else if (keys.BUTTON_ACCEPT) {
		if (s->var.stage.selected_stage == 4 && s->var.progress.stages < 255);
		else {
			s->load_level = d_stringtable_entry(s->config, stagename[s->var.stage.selected_stage]);
			s->newstate = STATE_TESTGAME;
		}
	}
			
	stageSelectMoveCursor();

	d_render_offset(0, 0);
	d_render_blend_enable();
	d_render_tile_draw(s->var.stage.stage, 10);
	d_render_blend_disable();

	
	return;
}
Esempio 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;
}