rotate_sprite_lit(3alleg4)

πŸ’– rotate_sprite_lit πŸ’–

okay bestie, so this one's from the Allegro manual (the 3alleg4 girlies know) and it's literally the glow-up version of sprite rotation β€” no cap, we're spinning sprites and they're gonna look so good while doing it. ✨


πŸŽ€ NAME πŸŽ€

rotate_sprite_lit β€” rotates a sprite. Allegro game programming library. yes that's the whole vibe. πŸ¦‹


✨ SYNOPSIS ✨

#include <allegro.h>

void rotate_sprite_lit(BITMAP *bmp, BITMAP *sprite,
                       int x, int y, fixed angle);

πŸ’… DESCRIPTION πŸ’…

so what this does: it draws the sprite image onto the bmp bitmap, and the way it lands is β€” top left corner goes at the position you specified, and then it gets rotated by the angle you gave it, spinning around its own centre. like it's doing a little twirl on the spot. 🧚

the angle is a fixed point 16.16 number, same format the fixed point trig routines use, and here's the cheat sheet you need to memorise fr fr:

  • 256 = a full circle πŸ”„
  • 64 = a right angle
  • etc. (iykyk)

and the best part?? all rotation functions can draw between any two bitmaps β€” even screen bitmaps, even bitmaps of different color depth. she's flexible. she's versatile. she's the main character. πŸ‘‘

now the part you actually need to know before you ship it: positive increments of the angle make the sprite rotate clockwise on the screen. this is demonstrated by the Allegro example, so go look at it if you want to see her in action. πŸ“

⚠️ heads up bestie: angle goes positive = clockwise. if you got it backwards your sprite's gonna spin the wrong way and you'll be sitting there like πŸ’€. no cap.

🌈 SEE ALSO 🌈

the whole friend group, all icons:


okay that's the whole page, go rotate something cute πŸ«ΆπŸ’œ

Allegro version 4.4.3 β€” rotate_sprite_lit(3alleg4), signing off, stay iconic, periodt. πŸ’…πŸŒΈβ­