imeluntuk
imeluntuk

Reputation: 395

Allegro 5 : Handling small sprite dimension in big resolution display

I'm new to game programming. Here I have some sprites, say Mario sprites in a spritesheet. It just 32 x 32 pixel for each sprite. One sprite contain one movement, full body of Mario. Unfortunately, I have to work at least with 800 x 640 display. As you might guess, Mario become look so small in display. So far, I'm just scale spritesheet in GIMP2 so that Mario doesn't look like ant in screen. Is there any way to handle it? Maybe Allegro has something I don't know. I already search it in documentation.

Upvotes: 0

Views: 399

Answers (1)

rcorre
rcorre

Reputation: 7218

It sounds like you want a way to scale an image within allegro. There are two was to achieve this:

  1. use al_draw_tinted_scaled_rotated_bitmap_region. Pass your scaling factor (e.g. 2.0) as the xscale and yscale arguments.

void al_draw_tinted_scaled_rotated_bitmap_region(ALLEGRO_BITMAP *bitmap,
   0, 0, 32, 32,              // draw the first 32x32 sprite in the sheet
   al_map_rgb(255, 255, 255), // don't tint the sprite
   16, 16,                    // the origin is 16, 16, half the 32x32 size
   200, 200,                  // draw at the point 200, 200 on the display
   2.0, 2.0,                  // scale by 2 in the x and y directions
   0, 0);                     // don't apply any angle or flags
  1. Use a transform to scale your image.

ALLEGRO_TRANSFORM trans;

al_identity_transform(&trans);
al_scale_transform(&trans, 2, 2); // scale by a factor of 2
al_use_transform(&trans);

// draw here

Note that in any case (including your original solution of scaling the spritesheet), scaling an image up will cause it to appear more pixellated.

Upvotes: 1

Related Questions