コード例 #1
0
int main(int argc, char* argv[])
{
    if(SDL_Init(SDL_INIT_EVERYTHING) == -1) {
        throw_SDLerror();
    }
    if(TTF_Init() == -1) {
        throw_SDLerror();
    }

    window = SDL_CreateWindow(GAME_TITLE, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, GAME_WIDTH, GAME_HEIGHT, SDL_WINDOW_RESIZABLE);
    renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
    SDL_RenderSetLogicalSize(renderer, GAME_WIDTH, GAME_HEIGHT);

    // TODO: black loading screen is boring.
    screen_clear();
    screen_display();

    asset_init();
    Player_create();
    Map_init();

    run();

    asset_quit();

    TTF_Quit();
    SDL_Quit();

    return 0;
}
コード例 #2
0
ファイル: font.c プロジェクト: svaarala/minisphere
static duk_ret_t
js_Font_drawZoomedText(duk_context* ctx)
{
	int x = duk_require_int(ctx, 0);
	int y = duk_require_int(ctx, 1);
	float scale = duk_require_number(ctx, 2);
	const char* text = duk_to_string(ctx, 3);
	
	ALLEGRO_BITMAP* bitmap;
	font_t*         font;
	color_t         mask;
	int             text_w, text_h;

	duk_push_this(ctx);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	if (!screen_is_skipframe(g_screen)) {
		text_w = get_text_width(font, text);
		text_h = get_font_line_height(font);
		bitmap = al_create_bitmap(text_w, text_h);
		al_set_target_bitmap(bitmap);
		draw_text(font, mask, 0, 0, TEXT_ALIGN_LEFT, text);
		al_set_target_backbuffer(screen_display(g_screen));
		al_draw_scaled_bitmap(bitmap, 0, 0, text_w, text_h, x, y, text_w * scale, text_h * scale, 0x0);
		al_destroy_bitmap(bitmap);
	}
	return 0;
}
コード例 #3
0
void CLS_DlgStreamPusher::screen_refresh(void *opaque)
{
	struct_stream_info* strct_streaminfo = (struct_stream_info*)opaque;
	if (NULL == strct_streaminfo){
		TRACE("NULL == strct_streaminfo");
		return;
	}

	screen_display(strct_streaminfo);
}
コード例 #4
0
void run()
{
    Uint32 currentTicks = 0;

    while(RUNNING)
    {
        Uint32 currentTicks = SDL_GetTicks();

        while(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                RUNNING = false;
            }

            if(event.type == SDL_KEYDOWN)
            {
                if(event.key.keysym.sym == SDLK_ESCAPE)
                {
                    RUNNING = false;
                }
            }

            Player_eventInput();
        }

        Player_gameInput();
        Map_update(); // includes entities

        screen_clear();

        Map_render(); // includes entities

        screen_display();

        if(SDL_GetTicks() - currentTicks < (1000 / GAME_FPS))
        {
            SDL_Delay((1000 / GAME_FPS) - (SDL_GetTicks() - currentTicks));
        }
    }

    SDL_DestroyRenderer(renderer);
    SDL_DestroyWindow(window);
}