Is there a way to flip a sprite horizontally or vertically?


As the title says, I am wondering if there is a way to flip a sprite either horizontally or vertically. I have search on the forum and on the Arduboy2 library Doc but nothing interesting pops out. Maybe I have search with the wrong keywords ? (actually : “flip” and “sprite”)

Does anyone have insight about that?

The ArdBitmap library written by @igvina can do this.

1 Like

Thanks for the answer, I’ll have a look about that, I doesn’t seem to have the nice feature of frame selection though !

But that’s easy enough to do with an array of pointers to individual frames.

I guess flipHorizontal() and flipVertical() only works for the display, and the display means the whole Arduboy screen…
Are there any algorithms and/or commands to flip sprites…
This whole Arduboy coding thing makes me feel like I’m working in a company like Nintendo coding a game in 1980s’ and 1990s’…

I think some of the libraries might have support for that. Flipping vertical is going to be SLOW though and probably should avoid if you are writing anything high performance. Flipping horizontal is just a matter of drawing the sprite “backwards” though, so not super difficult.

And if speed was of no concern at all you probably could build your own quite simply based on drawSlowBitmap, since all it’s doing it looping over every pixel.

I’m making an arcade-type game, featuring large sprites, where you traverse through stages, avoiding enemies, pushing boxes off ledges (which kills most enemies).
And if you defeat all the enemies in a level, the game gives you a key to open the door to the next stage.
An intermission appears after clearing a world.
So speed maybe important for this.

@igvina’s ArdBitmap library can.

1 Like

Does anybody know any commands to use it?
And how much memory does this library use on the hardware?

There are example sketches included with the library.

The compiler will only include the functions that you use, so the amount of memory the library uses will depend on which functions your sketch uses.

1 Like

Usually it’s flash space and CPU you have to worry about. Most utility libraries have low memory requirements.

Will the ArdBitmap library work with ARG sprites (“Sprites::”) or is it better to just take a storage hit?
I’m planning to add a secret hard mode where you play as the different character…
The intermissions make use of dithering…

What makes you think ArdBitmap sprites are larger than ARG sprites? Have you compared them? ArdBitmap can use compressed sprites, which may end up smaller.

I’m just asking if ArdBitmap can display sprites made using Team ARG Spritesheet Converter.
ARG sprites have masks…

I don’t think ArdBitmap bitmaps are compatible with ARG bitmaps.

You can do proper masking with ArdBitmap. You do it by writing two bitmaps at the same spot. When you draw a bitmap with colour WHITE, only the bits set to 1 in the bitmap will be drawn in white. When you draw a bitmap with colour BLACK, only the bits set to 1 in the bitmap will be drawn in black. Bits not set to 1 in either bitmap will be left unchanged from what they were in the buffer, thus “transparent”.


Are you asking a question?

Yes, I’m asking…

Then I don’t understand what your picture is trying to say.

Should I make 8 bitmaps (4 for black parts and 4 for white parts) or should I make 8 bitmaps (4 facing right, 4 facing left)?
It’s the matter of coding complexity, memory, space and speed… Planning to add a secret hard mode with a different player too…