Beispiel #1
0
int demo_initialize(int argc, char * argv[])
{
	if(!t3f_initialize(640, 480, 60.0, "Paintball Party 2 Tech Demo 2", demo_logic, demo_render, T3F_DEFAULT | T3F_USE_MOUSE | T3F_USE_JOYSTICK))
	{
		return 0;
	}
	demo_font = al_load_bitmap_font("demo_font.png");
	if(!demo_font)
	{
		printf("Failed to load font!\n");
		return 0;
	}
	
	t3f_3d_set_projection(&demo_camera.projection, 1.0, 1.0, 320.0, 240.0, 640, 640);
	t3f_3d_select_projection(&demo_camera.projection);
	
	demo_camera.x = 0.0;
	demo_camera.y = 0.0;
	demo_camera.z = 0.0;
	demo_camera.vx = 0;
	demo_camera.vy = 0;
	demo_camera.vw = al_get_display_width() / 2;
	demo_camera.vh = al_get_display_height() / 2;
	demo_camera.flags = 0;
	t3f_3d_set_projection(&demo_camera.projection, 0.5, 0.5, 320.0, 240.0, 640, 640);
	t3f_3d_select_projection(&demo_camera.projection);
	
	demo_tileset = t3f_load_tileset("export.ots");
	if(!demo_tileset)
	{
		return 0;
	}
	demo_tilemap = t3f_load_tilemap("export.otm");
	if(!demo_tilemap)
	{
		return 0;
	}
	demo_tilemap->tileset = demo_tileset;
	
	demo_collision_tilemap = t3f_load_collision_tilemap("export.ocm");
	if(!demo_collision_tilemap)
	{
		return 0;
	}
	
	sprite_ani[DEMO_SPRITE_STATE_STAND_RIGHT] = load_animation("mario_sr.ani");
	sprite_ani[DEMO_SPRITE_STATE_WALK_RIGHT] = load_animation("mario_wr.ani");
	sprite_ani[DEMO_SPRITE_STATE_JUMP_RIGHT] = load_animation("mario_jr.ani");
	sprite_ani[DEMO_SPRITE_STATE_FALL_RIGHT] = load_animation("mario_fr.ani");
	sprite_ani[DEMO_SPRITE_STATE_DUCK_RIGHT] = load_animation("mario_dr.ani");
	sprite_ani[DEMO_SPRITE_STATE_STAND_LEFT] = load_animation("mario_sl.ani");
	sprite_ani[DEMO_SPRITE_STATE_WALK_LEFT] = load_animation("mario_wl.ani");
	sprite_ani[DEMO_SPRITE_STATE_JUMP_LEFT] = load_animation("mario_jl.ani");
	sprite_ani[DEMO_SPRITE_STATE_FALL_LEFT] = load_animation("mario_fl.ani");
	sprite_ani[DEMO_SPRITE_STATE_DUCK_LEFT] = load_animation("mario_dl.ani");
	if(!sprite_ani)
	{
		return 0;
	}
	platform_ani = load_animation("platform.ani");
	if(!sprite_ani)
	{
		return 0;
	}
	
	platform.angle = 0.0;
	platform.x = 320 + cos(platform.angle) * 48.0;
	platform.y = 240 + sin(platform.angle) * 48.0;
	platform.cp = t3f_create_collision_object(0, 0, al_get_bitmap_width(platform_ani->bitmap[0]) * 2, al_get_bitmap_height(platform_ani->bitmap[0]) * 2, 32, 32, 0);
	platform.sticky = NULL;
/*	player.x = 0.0;
	player.y = 0.0;
	player.cp = t3f_create_collision_object(0, 0, 32, 32, 32, 32, 0);
	player.sticky = NULL;
	player.floor = 0; */
	
	player.cp = t3f_create_collision_object(5, 0, 22, 56, 32, 32, 0);
	player.x = 64.0;
	player.y = 64.0;
	player.vx = 0.0;
	player.vy = 0.0;
	player.sticky = NULL;
	player.floor = false;
	player.state = DEMO_SPRITE_STATE_STAND_RIGHT;
	player.frame = 0;
	
	controller = t3f_create_controller(4);
	if(!controller)
	{
		return 0;
	}
	al_clear_to_color(al_map_rgb(255, 0, 0));
	al_flip_display();
	t3f_bind_controller(controller, DEMO_CONTROLLER_UP);
	al_clear_to_color(al_map_rgb(0, 255, 0));
	al_flip_display();
	t3f_bind_controller(controller, DEMO_CONTROLLER_DOWN);
	al_clear_to_color(al_map_rgb(0, 0, 255));
	al_flip_display();
	t3f_bind_controller(controller, DEMO_CONTROLLER_LEFT);
	al_clear_to_color(al_map_rgb(0, 0, 0));
	al_flip_display();
	t3f_bind_controller(controller, DEMO_CONTROLLER_RIGHT);
	
	return 1;
}
bool initialize(int argc, char * argv[])
{
	const char * val;
	ALLEGRO_BITMAP * bp;
	
	process_arguments(argc, argv);
	if(!t3f_initialize(640, 480, 60.0, "The Devil", logic, render, T3F_DEFAULT | T3F_USE_MOUSE))
	{
		return false;
	}
	t3f_3d_set_projection(&projection, 0, 0, 640, 480, 320, 240);
	t3f_3d_select_projection(&projection);
	animation[ANIMATION_PLAYER] = t3f_load_animation_from_bitmap("data/player.png");
	if(!animation[ANIMATION_PLAYER])
	{
		return false;
	}
	animation[ANIMATION_DEMON] = t3f_load_animation_from_bitmap("data/demon.png");
	if(!animation[ANIMATION_DEMON])
	{
		return false;
	}
	animation[ANIMATION_ARCHDEMON] = t3f_load_animation_from_bitmap("data/archdemon.png");
	if(!animation[ANIMATION_ARCHDEMON])
	{
		return false;
	}
	animation[ANIMATION_PLAYER_SHOT] = t3f_load_animation_from_bitmap("data/player_shot.png");
	if(!animation[ANIMATION_PLAYER_SHOT])
	{
		return false;
	}
	animation[ANIMATION_ENEMY_SHOT] = t3f_load_animation_from_bitmap("data/enemy_shot.png");
	if(!animation[ANIMATION_ENEMY_SHOT])
	{
		return false;
	}
	animation[ANIMATION_SPIRIT] = t3f_create_animation();
	if(!animation[ANIMATION_SPIRIT])
	{
		return false;
	}
	bp = al_load_bitmap("data/spirit0.png");
	t3f_animation_add_bitmap(animation[ANIMATION_SPIRIT], bp);
	t3f_animation_add_frame(animation[ANIMATION_SPIRIT], 0, 0, 0, 0, al_get_bitmap_width(bp), al_get_bitmap_height(bp), 0, 5);
	bp = al_load_bitmap("data/spirit1.png");
	t3f_animation_add_bitmap(animation[ANIMATION_SPIRIT], bp);
	t3f_animation_add_frame(animation[ANIMATION_SPIRIT], 1, 0, 0, 0, al_get_bitmap_width(bp), al_get_bitmap_height(bp), 0, 5);
	bp = al_load_bitmap("data/spirit2.png");
	t3f_animation_add_bitmap(animation[ANIMATION_SPIRIT], bp);
	t3f_animation_add_frame(animation[ANIMATION_SPIRIT], 2, 0, 0, 0, al_get_bitmap_width(bp), al_get_bitmap_height(bp), 0, 5);
	animation[ANIMATION_LOGO] = t3f_load_animation_from_bitmap("data/logo.png");
	if(!animation[ANIMATION_LOGO])
	{
		return false;
	}
	animation[ANIMATION_TITLE] = t3f_load_animation_from_bitmap("data/title_logo.png");
	if(!animation[ANIMATION_TITLE])
	{
		return false;
	}
	sprite_sheet = al_create_bitmap(512, 512);
	if(!sprite_sheet)
	{
		return false;
	}
	t3f_start_sprite_sheet(sprite_sheet, T3F_SPRITE_SHEET_TYPE_SPRITES);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_PLAYER]);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_DEMON]);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_ARCHDEMON]);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_PLAYER_SHOT]);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_ENEMY_SHOT]);
	t3f_add_animation_to_sprite_sheet(animation[ANIMATION_SPIRIT]);
	t3f_finish_sprite_sheet();
	font[FONT_GAME] = al_load_bitmap_font("data/default_font.png");
	if(!font[FONT_GAME])
	{
		return false;
	}
	sample[SAMPLE_GAME_OVER] = al_load_sample("data/game_over.ogg");
	if(!sample[SAMPLE_GAME_OVER])
	{
		return false;
	}
	sample[SAMPLE_LEVEL_UP] = al_load_sample("data/level_up.ogg");
	if(!sample[SAMPLE_LEVEL_UP])
	{
		return false;
	}
	sample[SAMPLE_MAX_MULTIPLIER] = al_load_sample("data/max_multiplier.ogg");
	if(!sample[SAMPLE_MAX_MULTIPLIER])
	{
		return false;
	}
	sample[SAMPLE_HIGH_SCORE] = al_load_sample("data/high_score.ogg");
	if(!sample[SAMPLE_HIGH_SCORE])
	{
		return false;
	}
	sample[SAMPLE_TWIN_SHOT] = al_load_sample("data/twin_shot.ogg");
	if(!sample[SAMPLE_TWIN_SHOT])
	{
		return false;
	}
	sample[SAMPLE_TRIPLE_SHOT] = al_load_sample("data/triple_shot.ogg");
	if(!sample[SAMPLE_TRIPLE_SHOT])
	{
		return false;
	}
	sample[SAMPLE_POWERUP] = al_load_sample("data/powerup.ogg");
	if(!sample[SAMPLE_POWERUP])
	{
		return false;
	}
	sample[SAMPLE_SHOOT] = al_load_sample("data/shoot.ogg");
	if(!sample[SAMPLE_SHOOT])
	{
		return false;
	}
	sample[SAMPLE_HIT] = al_load_sample("data/hit.ogg");
	if(!sample[SAMPLE_HIT])
	{
		return false;
	}
	sample[SAMPLE_DIE] = al_load_sample("data/die.ogg");
	if(!sample[SAMPLE_DIE])
	{
		return false;
	}
	sample[SAMPLE_MULTIPLIER] = al_load_sample("data/multiplier.ogg");
	if(!sample[SAMPLE_MULTIPLIER])
	{
		return false;
	}
	cinema = load_cinema("data/intro.cin", 0);
	if(!cinema)
	{
		return false;
	}
	ending_cinema = load_cinema("data/ending.cin", 0);
	if(!ending_cinema)
	{
		return false;
	}
	level_color[0] = al_map_rgba(131, 0, 0, 255);
	level_color[1] = al_map_rgba(131, 22, 0, 255);
	level_color[2] = al_map_rgba(131, 46, 0, 255);
	level_color[3] = al_map_rgba(131, 68, 0, 255);
	level_color[4] = al_map_rgba(131, 99, 0, 255);
	level_color[5] = al_map_rgba(131, 126, 0, 255);
	level_color[6] = al_map_rgba(101, 131, 0, 255);
	level_color[7] = al_map_rgba(77, 131, 0, 255);
	level_color[8] = al_map_rgba(0, 131, 73, 255);
	level_color[9] = al_map_rgba(0, 105, 131, 255);
	level_color[10] = al_map_rgba(0, 135, 254, 255);
	hyperlink_set_driver(NULL);
	val = al_get_config_value(t3f_config, "Save Data", "High Score");
	if(val)
	{
		high_score = atoi(val);
	}
	t3f_play_music("data/title.xm", 0.0, 0.0);
	state = STATE_LOGO;
	return true;
}