draw_sprite_v_flip(3alleg4)
π draw_sprite_v_flip β the Allegro manual, but make it cute π
okay bestie, we're in the Allegro manual (that's the 3alleg4 section, the game programming library one) and today's main character is a whole little trio of functions that draw your sprite but flipped. yes. mirror mode. slay.
β¨ NAME β¨
draw_sprite_v_flip, draw_sprite_h_flip, draw_sprite_vh_flip β they draw the sprite transformed onto the destination bitmap. that's the Allegro game programming library, periodt.
πΈ SYNOPSIS πΈ
#include <allegro.h>
void draw_sprite_v_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
void draw_sprite_h_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
void draw_sprite_vh_flip(BITMAP *bmp, BITMAP *sprite, int x, int y);
π¦ DESCRIPTION π¦
so these are literally just like draw_sprite(), except they also flip the image. that's it. that's the whole vibe.
draw_sprite_v_flipflips it verticallydraw_sprite_h_flipflips it horizontallydraw_sprite_vh_flipflips it both ways (overachiever behavior, we love it)
and what does flipping actually mean here? okay so flipping vertically = the y-axis is reversed, and flipping horizontally = the x-axis is reversed, between the source and the destination. it's giving mirror. it's giving reflection.
and here's the tea: this produces exact mirror images, which is NOT the same thing as rotating the sprite. also it is a lot faster than the rotation routine, so if you just want a mirrored sprite, don't be doing the whole rotation thing, okay? it's not that deep. π₯
heads up bestie: the sprite must be a memory bitmap. no cap. don't come crying to me later.
example time, look at this little animation logic, it ate:
if (key[KEY_RIGHT])
draw_sprite(screen, hero_right, pos_x, pos_y);
else if (key[KEY_LEFT])
draw_sprite_h_flip(screen, hero_right, pos_x, pos_y);
else
draw_sprite(screen, hero_idle, pos_x, pos_y);
see how the hero just flips to face left instead of you needing a whole second bitmap? iconic. efficient. main character energy. π
π SEE ALSO π
draw_sprite(3alleg4)β the original, the blueprint, the blueprint's blueprintbitmap_mask_color(3alleg4)β for all your masking needsexsprite(3alleg4)β the example, go read it, iykyk
okay and finally, the little sign-off at the bottom of the page: this is Allegro, version 4.4.3, and the page is draw_sprite_v_flip(3alleg4). that's the whole footer. mwah. π go flip something, bestie. π«Ά
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms