|
|
| Drawing a sprite with an origin outside the screen |
|
Ionising
Member #14,522
August 2012
|
I was wondering what the best way to draw an image part way outside the screen is? I'd like to do this in order to display only a section of the image to fill in gaps in my isometric engine. I notice when I call al_draw_bitmap with a dx/dy less than zero nothing is displayed even if part of the image should still be visible. Example of what I am trying to achieve: |
|
Elias
Member #358
May 2000
|
Can you show the code? -- |
|
Ionising
Member #14,522
August 2012
|
Screenshots of my test app showing the problem: I've wrapped up Allegro into a game library, but drawing the image boils down to one call: al_draw_bitmap( pImage, nXPositionPx, nYPx, nFlags ); |
|
Malinus
Member #11,332
September 2009
|
I would do something like this (lets say you don't know the size of the bitmap, but it get the -150;-150 coordinate (and the bitmap is bigger then 150x150 of course)): 1
2int x = -150;
3int y = -150;
4
5al_draw_bitmap_region(bitmap, fabs(x), fabs(y), al_get_bitmap_width(bitmap)-fabs(x), al_get_bitmap_height(bitmap)-fabs(y), 0, 0, NULL)
I haven't tried it, but it should work |
|
Neil Walker
Member #210
April 2000
|
Not exactly related, but seeing as you're playing with isometric stuff here's something you might find interesting... Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
|
Dizzy Egg
Member #10,824
March 2009
|
You shouldn't need to chop the image at all, it should display as you would expect. Are you sure you're not using unsigned int for X and Y
---------------------------------------------------- |
|
weapon_S
Member #7,859
October 2006
|
<obvious>Are you really calling al_draw_bitmap directly? I.e. you don't have a condition somewhere that prevents bitmaps with negative values to be drawn? Apply palm to face, if applicable.</obvious> |
|
|