Esempio n. 1
0
/* start the game from level 0 */
void dot_game_initialize(void * data, bool demo_seed)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;

    if(demo_seed)
    {
        t3f_srand(&app->rng_state, app->demo_seed);
    }
    else
    {
        t3f_srand(&app->rng_state, time(0));
    }
	dot_game_setup_level(data, 0);
	app->game.score = 0;
	app->game.combo = 0;
	app->game.lives = 3;
	app->game.shield.active = false;
	app->game.old_bg_color = app->level_color[0];
	app->game.bg_color_fade = 0.0;
	if(app->music_enabled)
	{
		t3f_play_music(DOT_MUSIC_BGM);
	}
	app->game.tick = 0;
	app->state = DOT_STATE_GAME;
}
Esempio n. 2
0
void paddle_game_init(void)
{
	al_hide_mouse_cursor(t3f_display);
	
	/* place paddles */
	paddle[0].x = 32.0;
	paddle[0].y = 240.0 - 64.0 / 2.0;
	paddle[0].object = t3f_create_collision_object(0, 0, 16, 64, 32, 32, 0);
	t3f_move_collision_object_xy(paddle[0].object, paddle[0].x, paddle[0].y);
	paddle[0].active = true;
	paddle[1].x = 640.0 - 32.0 - 16.0;
	paddle[1].y = 240.0 - 64.0 / 2.0;
	paddle[1].object = t3f_create_collision_object(0, 0, 16, 64, 32, 32, 0);
	t3f_move_collision_object_xy(paddle[1].object, paddle[1].x, paddle[1].y);
	paddle[1].active = true;
	
	/* place ball */
	ball.object = t3f_create_collision_object(0, 0, 16, 16, 32, 32, 0);
	paddle_init_ball(1.0);
	
	/* reset scores */
	score[0] = 0;
	score[1] = 0;
	
	t3f_srand(&rng_state, time(0));
	
	paddle_state = EXAMPLE_STATE_GAME;
	t3f_play_music("data/music/game.xm");
}
Esempio n. 3
0
int main(int argc, char * argv[])
{
	int i;
	char fn[1024] = {0};

	if(!t3f_initialize("ex_atlas", 640, 480, 60.0, logic, render, T3F_USE_KEYBOARD | T3F_USE_MOUSE, NULL))
	{
		return 1;
	}
	t3f_srand(&rng_state, time(0));

	/* load bitmaps into sprite sheet */
	atlas = t3f_create_atlas(512, 512);
	if(!atlas)
	{
		printf("Failed to create atlas!\n");
		return 0;
	}
	for(i = 0; i < 8; i++)
	{
		sprintf(fn, "data/%d.png", i);
		bitmap[i] = al_load_bitmap(fn);
		if(!bitmap[i])
		{
			return 1;
		}
		t3f_add_bitmap_to_atlas(atlas, &bitmap[i], T3F_ATLAS_SPRITE);
	}

	for(i = 0; i < 1024; i++)
	{
		object[i].x = t3f_drand(&rng_state) * 640.0;
		object[i].y = t3f_drand(&rng_state) * 480.0;
		object[i].vx = t3f_drand(&rng_state) * 4.0 - 2.0;
		object[i].vy = t3f_drand(&rng_state) * 4.0 - 2.0;
		object[i].bitmap = t3f_rand(&rng_state) % 8;
	}
	t3f_run();
	return 0;
}
Esempio n. 4
0
void dot_setup_bg_objects(void * data)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;
	int i;
	float s, a;

	t3f_srand(&dot_bg_rng_state, time(0));

	/* initialize background objects */
	memset(app->bg_object, 0, sizeof(DOT_BG_OBJECT) * DOT_MAX_BG_OBJECTS);
	a = ALLEGRO_PI / 8.0; // angle slightly toward the player
	for(i = 0; i < DOT_MAX_BG_OBJECTS; i++)
	{
		s = t3f_drand(&dot_bg_rng_state) * 0.5 + 0.25;
		s = 0.25;
		app->bg_object[i].x = t3f_drandom(&dot_bg_rng_state, DOT_GAME_PLAYFIELD_WIDTH + DOT_GAME_BALL_SIZE) - DOT_GAME_BALL_SIZE;
		app->bg_object[i].y = t3f_drandom(&dot_bg_rng_state, DOT_GAME_PLAYFIELD_HEIGHT + DOT_GAME_BALL_SIZE) - DOT_GAME_BALL_SIZE;
		app->bg_object[i].z = -t3f_drandom(&dot_bg_rng_state, 320.0);
		app->bg_object[i].vx = -cos(a) * s;
		app->bg_object[i].vy = 0.0;
		app->bg_object[i].vz = -sin(a) * s;
	}
}