Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Resizing the game

This thread is locked; no one can reply to it. rss feed Print
Resizing the game
Atrevido
Member #16,069
September 2015

Hello, first i apologyze for my bad english.

I'm new in the allegro world, so i've some basic concepts about allegro programming.

My question is how to resize the game (images, sprites, etc..) depending of the resolution. I'm making a game in fullscreen using the flag ALLEGRO_FULLSCREEN_WINDOW, and the display gets the screen resolution, but the images don't change the size.

I really apreciate any help you can give me, i hope you understand my query ;D
I'm using allegro 5.0

Mark Oates
Member #1,146
March 2001
avatar

What I do is scale the entire surface using an ALLEGRO_TRANSFORM. The dead simplest way might be something like this:

ALLEGRO_TRANSFORM t;
al_identity_transform(&t);
al_scale_transform(&t, 3.0, 3.0); // scaled by 3
al_use_transform(&t);

// now draw all your stuff, which will now be scaled
draw_stuff();

This method should work if you aren't using any other transforms in your code.

If you want the ALLEGRO_FULLSCREEN to match the native dimensions of your smaller window, then your scale would be screen_size_width/native_size_width.

Most likely you will find some tweaking will be necessary.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Atrevido
Member #16,069
September 2015

thanks for your quick response! I followed your advice and it worked perfectly, thank you very much for the help!! ;D

Regards.

Go to: