Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Drawing bitmap on the display rather than on the map

This thread is locked; no one can reply to it. rss feed Print
Drawing bitmap on the display rather than on the map
Themilkshake
Member #17,095
June 2019

Hello everyone,
I recently started to use the allegro5 library and am trying to make a local multiplayer game but i have the following problem : When I draw my character sprites I use the al_draw_bitmap_region() function, but it seems to always draw my character in positions relating to my screen. Therefore, when I try to draw the second character it cannot stay on the map outside my window( the map is way larger than the screen i created ).
Any help would be appreciated!

Edgar Reynaldo
Member #8,592
May 2007
avatar

What you're looking for is al_set_target_bitmap. The coordinates are on the target bitmap, so whatever you set it to be, that is where they will be drawn.

Reset the drawing target to the backbuffer when you're done.
al_set_target_backbuffer(display);
OR
al_set_target_bitmap(al_get_backbuffer(display));

EDIT

OR maybe I misunderstood what you want.

If you're drawing to the map, you need map coordinates, if you're drawing to the screen, you need screen coordinates.

To relate the two together, take the position on your map, and subtract it from your player's map coordinates. This will give you the screen coordinates of your player (whether they are on screen or not).

Themilkshake
Member #17,095
June 2019

Thank you very much, I got it working properly now!

Edgar Reynaldo
Member #8,592
May 2007
avatar

Go to: