示例#1
0
void
show_mouse_cursor (void)
{
  if (! al_show_mouse_cursor (display))
    error (0, 0, "%s (void): cannot show mouse cursor",
           __func__);
}
示例#2
0
文件: pause.c 项目: dos1/SuperDerpy
int Pause_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
	if ((game->menu.menustate==MENUSTATE_OPTIONS) && ((ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) || ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (game->menu.selected==3)))) {
		al_play_sample_instance(game->menu.click);
		ChangeMenuState(game,MENUSTATE_PAUSE);
	} else if ((game->menu.menustate==MENUSTATE_VIDEO) && ((ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) || ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (game->menu.selected==3)))) {
		al_play_sample_instance(game->menu.click);
		ChangeMenuState(game,MENUSTATE_OPTIONS);
		if (game->menu.options.fullscreen!=game->fullscreen) {
			al_toggle_display_flag(game->display, ALLEGRO_FULLSCREEN_WINDOW, game->menu.options.fullscreen);
			al_clear_to_color(al_map_rgb(0,0,0));
			al_flip_display();
			game->fullscreen = game->menu.options.fullscreen;
			if (game->fullscreen) al_hide_mouse_cursor(game->display);
			else al_show_mouse_cursor(game->display);
			Shared_Unload(game);
			al_clear_to_color(al_map_rgb(0,0,0));
			al_flip_display();
			SetupViewport(game);
			Shared_Load(game);

#ifndef __clang__
			void Progress(struct Game *game, float p) {
				al_set_target_bitmap(al_get_backbuffer(game->display));
				al_clear_to_color(al_map_rgb(0,0,0));
				al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), game->viewportWidth*0.0234, game->viewportHeight*0.84, ALLEGRO_ALIGN_LEFT, "Loading...");
				al_draw_filled_rectangle(0, game->viewportHeight*0.985, game->viewportWidth, game->viewportHeight, al_map_rgba(128,128,128,128));
				al_draw_filled_rectangle(0, game->viewportHeight*0.985, p*game->viewportWidth, game->viewportHeight, al_map_rgba(255,255,255,255));
				al_flip_display();
			}
示例#3
0
void paddle_game_exit(void)
{
	t3f_destroy_collision_object(paddle[0].object);
	t3f_destroy_collision_object(paddle[1].object);
	t3f_destroy_collision_object(ball.object);
	al_show_mouse_cursor(t3f_display);
	t3f_play_music("data/music/menu.xm");
	paddle_state = EXAMPLE_STATE_TITLE;
}
示例#4
0
void Mouse::Update() {

    _prevState = _curState;
    al_get_mouse_state(&_curState);

    if(_cursor) {
        al_set_mouse_cursor(_parent_display, _cursor);
    } else {
        al_set_system_mouse_cursor(_parent_display, _cursor_id);
    }
    _isVisible ?  al_show_mouse_cursor(_parent_display) : al_hide_mouse_cursor(_parent_display);
}
示例#5
0
int fb_init(){
    BACKGROUND_COLOR=al_map_rgb(0,127,255);
    al_show_mouse_cursor(Engine_Display);
    start_button = new button();
    start_button->set_values("../res/start_button.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2+50,0,0);
    start_button->on_click=&start_cb;
    quit_button = new button();
    quit_button->set_values("../res/quit_button.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2+200,0,0);
    quit_button->on_click=&quit_cb;
    bird_frames[0]=al_load_bitmap("../res/fb_wu.png");
    bird_frames[1]=al_load_bitmap("../res/fb_wd.png");
    my_pipe::pipe_image=al_load_bitmap("../res/pipe.png");
    background = new image("../res/background.png",DISPLAY_WIDTH,DISPLAY_HEIGHT/2,-3,0);
    bird = new collision_object<image>;
    menu = new image("../res/menu.png",DISPLAY_WIDTH/2,DISPLAY_HEIGHT/2,0,0);
    bird->set_values(bird_frames[0],bird_x,DISPLAY_HEIGHT+50,0,0);
    fb_timer = al_create_timer(TIME_BETWEEN_PIPES);
    al_register_event_source(engine_event_queue, al_get_timer_event_source(fb_timer));
    if(!fb_timer){
        std::cerr << "Couldn't create fb_timer!" << std::endl;
        return -1;
    }
#ifdef NDEBUG
    hscore_font=al_load_ttf_font("../res/xkcd-Regular.otf",24,0);
#else
    hscore_font=al_load_ttf_font("../res/xkcd-Regular.otf",36,0);
#endif
    if(!hscore_font){
        std::cerr << "Couldn't load font xkcd-Regular.otf!" << std::endl;
        return -1;
    }
    score_string = new string(5,0,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    score_string->auto_render=1;
    score_string->color=al_map_rgb(255,255,0);
#ifdef NDEBUG
    tick_string = new string(5,30,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    tick_string->auto_render=1;
    tick_string->color=al_map_rgb(255,255,0);
    vel_string = new string(5,60,0,0,new char[256], hscore_font,ALLEGRO_ALIGN_LEFT,0,0);
    vel_string->auto_render=1;
    vel_string->color=al_map_rgb(255,255,0);
#endif
    create_pipe();
    al_start_timer(fb_timer);
    return 0;
}
示例#6
0
文件: theend.c 项目: dos1/mediator
void Gamestate_Start(struct Game *game, struct dosowiskoResources* data) {
	  al_set_sample_instance_gain(game->data->muzyczka.instance.drums, 0.0);
		al_set_sample_instance_gain(game->data->muzyczka.instance.fg, 0.0);
		al_set_sample_instance_gain(game->data->muzyczka.instance.bg, 1.5);

		char *end = "";
		data->score = strtol(GetConfigOptionDefault(game, "Mediator", "score", "0"), &end, 10);

		if (game->data->mediator.score > data->score) {
			  char text[255];
				snprintf(text, 255, "%d", game->data->mediator.score);
				SetConfigOption(game, "Mediator", "score", text);
				data->score = game->data->mediator.score;
		}

		al_ungrab_mouse();
		if (!game->config.fullscreen) al_show_mouse_cursor(game->display);

		al_play_sample_instance(data->sound);

}
示例#7
0
 v8::Handle<v8::Value> show(const v8::Arguments& args) {
     al_show_mouse_cursor(Game::allegro.display);
     return v8::Undefined();
 }
示例#8
0
/* the main game logic function */
void dot_game_logic(void * data)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;

	int colored = 0;
	float rgb = 1.0;
	int i, m;

	/* handle level bg color transition */
	if(app->game.bg_color_fade < 1.0)
	{
		app->game.bg_color_fade += 1.0 / 60.0;
		if(app->game.bg_color_fade > 1.0)
		{
			app->game.bg_color_fade = 1.0;
		}
	}

	/* make level colors darker after every 10 levels */
	m = app->game.level / 10;
	for(i = 0; i < m; i++)
	{
		rgb *= 0.75;
	}
	app->game.bg_color = dot_darken_color(dot_transition_color(app->game.old_bg_color, app->level_color[app->game.level % 10], app->game.bg_color_fade), rgb);

	dot_game_emo_logic(data);
	dot_bg_objects_logic(data, app->game.speed);
	switch(app->game.state)
	{

		/* balls move slow for a few seconds so player can get ready */
		case DOT_GAME_STATE_START:
		{
			app->game.state_tick++;
			if(app->touch_id >= 0)
			{
				if(app->touch_x >= DOT_GAME_TOUCH_START_X && app->touch_x < DOT_GAME_TOUCH_END_X && app->touch_y >= DOT_GAME_TOUCH_START_Y && app->touch_y < DOT_GAME_TOUCH_END_Y)
				{
					t3f_play_sample(app->sample[DOT_SAMPLE_GO], 1.0, 0.0, 1.0);
					app->game.state = DOT_GAME_STATE_PLAY;
					app->game.state_tick = 0;
					app->game.player.lost_touch = false;
					app->game.player.ball.active = true;
					app->game.player.want_shield = true;
					app->game.player.touch_offset_x = 0;
					app->game.player.touch_offset_y = 0;
					app->game.level_start = false;
					al_hide_mouse_cursor(t3f_display);
				}
			}

			/* handle ball logic */
			colored = dot_game_move_balls(data);
			break;
		}

		case DOT_GAME_STATE_PAUSE:
		{
			if(app->touch_id >= 0 && t3f_distance(app->touch_x, app->touch_y, app->game.player.ball.x, app->game.player.ball.y) < DOT_GAME_GRAB_SPOT_SIZE)
			{
				app->game.player.touch_offset_x = app->game.player.ball.x - app->touch_x;
				app->game.player.touch_offset_y = app->game.player.ball.y - app->touch_y;
				app->game.state = DOT_GAME_STATE_PLAY;
				al_hide_mouse_cursor(t3f_display);
			}
			break;
		}

		case DOT_GAME_STATE_DONE:
		{
			for(i = 0; i < DOT_MAX_PARTICLES; i++)
			{
				if(app->particle[i].active)
				{
					break;
				}
			}
			if(i == DOT_MAX_PARTICLES)
			{
				dot_game_exit(data);
			}
			break;
		}

		/* normal game state */
		default:
		{
			/* handle shield logic */
			dot_game_shield_logic(data);

			/* move player */
			dot_game_move_player(data);

			/* handle ball logic */
			colored = dot_game_move_balls(data);

			dot_game_check_player_collisions(data);

			/* move on to next level */
			if(colored == 0)
			{
				dot_game_accumulate_score(data);
				for(i = 0; i < DOT_GAME_MAX_BALLS; i++)
				{
					if(app->game.ball[i].active && app->game.ball[i].type == 6)
					{
						dot_game_create_splash_effect(data, app->game.ball[i].x, app->game.ball[i].y, app->game.ball[i].r, app->dot_color[app->game.ball[i].type]);
					}
				}
				if(app->touch_id >= 0)
				{
					t3f_touch[app->touch_id].active = false;
				}
				al_show_mouse_cursor(t3f_display);
				app->game.old_bg_color = app->game.bg_color;
				dot_game_setup_level(data, app->game.level + 1);
				app->game.bg_color_fade = 0.0;
				app->game.combo = 0;
				app->game.shield.active = false;
			}
			break;
		}
	}
	if(t3f_key[ALLEGRO_KEY_ESCAPE] || t3f_key[ALLEGRO_KEY_BACK])
	{
		dot_intro_setup(data);
		app->state = DOT_STATE_INTRO;
		if(app->music_enabled)
		{
			t3f_play_music(DOT_MUSIC_TITLE);
		}
		t3f_key[ALLEGRO_KEY_ESCAPE] = 0;
		t3f_key[ALLEGRO_KEY_BACK] = 0;
	}
	app->game.tick++;
}
示例#9
0
/* handle player movement */
void dot_game_move_player(void * data)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;

	float ox, oy, target_angle;

	if(app->game.player.ball.active)
	{
		ox = app->game.player.ball.x;
		oy = app->game.player.ball.y;

		if(app->touch_id >= 0)
		{
			if(app->game.player.lost_touch)
			{
				if(t3f_distance(app->touch_x, app->touch_y, app->game.player.ball.x, app->game.player.ball.y) < DOT_GAME_GRAB_SPOT_SIZE)
				{
					app->game.player.lost_touch = false;
				}
			}
			if(!app->game.player.lost_touch)
			{
				app->game.player.ball.x = app->touch_x + app->game.player.touch_offset_x;
				app->game.player.ball.y = app->touch_y + app->game.player.touch_offset_y;
			}
			if(app->game.player.want_shield)
			{
				app->game.shield.x = app->game.player.ball.x;
				app->game.shield.y = app->game.player.ball.y;
				app->game.shield.r = app->game.player.ball.r + 1.0;
				app->game.shield.active = true;
				app->game.player.want_shield = false;
			}
		}
		else
		{
			app->game.player.lost_touch = true;
			app->game.state = DOT_GAME_STATE_PAUSE;
			al_show_mouse_cursor(t3f_display);
		}

		/* prevent player from moving past the edge */
		if(app->game.player.ball.x - app->game.player.ball.r < 0.0)
		{
			app->game.player.ball.x = app->game.player.ball.r;
		}
		if(app->game.player.ball.x + app->game.player.ball.r >= DOT_GAME_PLAYFIELD_WIDTH)
		{
			app->game.player.ball.x = DOT_GAME_PLAYFIELD_WIDTH - app->game.player.ball.r;
		}
		if(app->game.player.ball.y - app->game.player.ball.r < 0.0)
		{
			app->game.player.ball.y = app->game.player.ball.r;
		}
		if(app->game.player.ball.y + app->game.player.ball.r >= DOT_GAME_PLAYFIELD_HEIGHT)
		{
			app->game.player.ball.y = DOT_GAME_PLAYFIELD_HEIGHT - app->game.player.ball.r;
		}

		/* if the player has moved, change the angle of the character */
		if((int)ox != (int)app->game.player.ball.x || (int)oy != (int)app->game.player.ball.y)
		{
			target_angle = atan2(oy - app->game.player.ball.y, ox - app->game.player.ball.x);
			if(fabs(target_angle - app->game.player.ball.a) > ALLEGRO_PI / 16.0)
			{
				app->game.player.ball.a += (ALLEGRO_PI / 16.0) * get_angle_dir(target_angle, app->game.player.ball.a);
				if(app->game.player.ball.a > ALLEGRO_PI)
				{
					app->game.player.ball.a -= ALLEGRO_PI * 2.0;
				}
				if(app->game.player.ball.a < -ALLEGRO_PI)
				{
					app->game.player.ball.a += ALLEGRO_PI * 2.0;
				}
			}
		}

		/* handle combo timer */
		if(app->game.combo > 0)
		{
			app->game.player.ball.timer++;
			if(app->game.player.ball.timer >= DOT_GAME_COMBO_TIME)
			{
				if(app->game.combo >= 10)
				{
					app->game.emo_tick = 60;
					app->game.emo_state = DOT_GAME_EMO_STATE_WOAH;
				}
				dot_game_accumulate_score(data);
				app->game.player.ball.timer = 0;
				app->game.combo = 0;
				app->game.shield.active = false;
				t3f_play_sample(app->sample[DOT_SAMPLE_SCORE], 1.0, 0.0, 1.0);
			}
		}
	}
}
示例#10
0
void dot_game_check_player_collisions(void * data)
{
	APP_INSTANCE * app = (APP_INSTANCE *)data;
	int i, j;

	/* see if player ball hits any other balls */
	for(i = 0; i < DOT_GAME_MAX_BALLS; i++)
	{
		if(app->game.ball[i].active)
		{
			if(t3f_distance(app->game.ball[i].x, app->game.ball[i].y, app->game.player.ball.x, app->game.player.ball.y) < app->game.player.ball.r + app->game.ball[i].r)
			{
				/* hitting the same color gives you points and increases your combo */
				if(app->game.ball[i].type == app->game.player.ball.type)
				{
					t3f_play_sample(app->sample[DOT_SAMPLE_GRAB], 1.0, 0.0, 1.0);
					app->game.ball[i].active = false;
					if(app->game.player.ball.timer < DOT_GAME_COMBO_TIME)
					{
						app->game.combo++;
					}
					app->game.ascore = dot_game_get_combo_score(data);
					app->game.player.ball.timer = 0;
					for(j = 0; j < DOT_GAME_MAX_BALLS; j++)
					{
						if(app->game.ball[j].active && app->game.ball[j].type != DOT_BITMAP_BALL_BLACK && app->game.ball[j].type != app->game.player.ball.type)
						{
							app->game.ball[j].type = app->game.player.ball.type;
							app->game.ball[j].target_tick = DOT_GAME_TARGET_TICKS;
							break;
						}
					}
					app->game.speed += app->game.speed_inc;
					dot_game_create_splash_effect(data, app->game.ball[i].x, app->game.ball[i].y, app->game.ball[i].r, app->dot_color[app->game.ball[i].type]);
				}

				/* hitting other color kills you */
				else
				{
					if(app->touch_id >= 0)
					{
						t3f_touch[app->touch_id].active = false;
					}
					dot_game_create_splash_effect(data, app->game.player.ball.x, app->game.player.ball.y, app->game.player.ball.r, app->dot_color[app->game.player.ball.type]);
					t3f_play_sample(app->sample[DOT_SAMPLE_LOSE], 1.0, 0.0, 1.0);
					dot_game_accumulate_score(data);
					app->game.combo = 0;
					app->game.shield.active = false;
					app->game.lives--;
					app->game.emo_tick = 60;
					app->game.emo_state = DOT_GAME_EMO_STATE_DEAD;

					/* change ball color to match the ball that is hit unless it is black */
					if(app->game.ball[i].type != DOT_BITMAP_BALL_BLACK)
					{
						if(app->game.lives > 0)
						{
							dot_game_drop_player(data, app->game.ball[i].type);
							dot_game_target_balls(data, app->game.player.ball.type);
						}
						else
						{
							app->game.player.ball.active = false;
							app->game.state = DOT_GAME_STATE_DONE;
						}
					}
					else
					{
						if(app->game.lives > 0)
						{
							dot_game_drop_player(data, app->game.player.ball.type);
						}
						else
						{
							app->game.player.ball.active = false;
							app->game.state = DOT_GAME_STATE_DONE;
						}
					}
					al_show_mouse_cursor(t3f_display);
					break;
				}
			}
		}
	}
}
示例#11
0
文件: mouse.c 项目: sanikoyes/tools
static int allua_mouse_show_cursor(lua_State * L)
{
   ALLUA_display display = allua_check_display(L, 1);
   lua_pushboolean(L, al_show_mouse_cursor(display));
   return 1;
}