Sprite scaling on the Arduboy

I want to be able to make a sprite / bitmap get bigger or smaller on screen. How would you recommend making that happen? Is there a good code example for it anywhere? I obviously can’t be the first person who wants to do this.

Im working on a Wolfenstein 3D style game. Already got white walls and black floor/ceiling where you can walk around the environment. Now I want to add enemies next

That was me posting this. Not sure why it logged me on as “anonymous”

The arduboy lib doesn’t have any support for this.
It’s a non-trivial process to do this. There are numerous ways to implement this.
One of the simplest ways would be nearest neighbor with integer scaling.

Wikipedia has a very good article about it. link

You will need to implement it yourself with drawing code for the display.
Also you have to keep in mind that you only have 2.5 kb of ram available and one fullscreen image (128x64) already eats up 1kb.

There is one trivial method the lib can employ



I dont need scaled up but I do need scaled down. I’m trying to make a Wolfenstein 3D style game and need to scale enemy sprites as they get closer or further away.

There might only be room for one enemy sprite. I’d be OK with that as long as it scales smoothly.

(Later edit) Or maybe the sprite should be stored at half the maximum on screen size? That would save in memory, if a nice nearest neighbor scaling implentation is available

1 Like

Another thought: Perhaps if I can’t get sprite scaling, maybe I can define my enemies appearance as drawable using vector graphics. They could be boxes with angry face.

I don’t think it just scaling a spite/vector art will be enough. I think in a raycaster the sprites should also be drawn line by line (just like the walls) so they can be partly behind walls.

Perhaps. Or perhaps you just draw the walls over on top of the sprites

You might look at using AVL trees and giving each node a coordinate for a vector. This way you can quickly parse the tree and see which coordinates/nodes are visible to the user.

As I understand it, AVL trees is how Doom worked. But I’m just trying to do Wolfenstein style stuff. Going as far as Doom is not a reasonable goal at this point.

An AVL tree is just a type of binary tree that can be used to store and quickly parse information, O(log(n)) for access, sort etc. It’s merely a container that can be used to store any information for quick retrieval. And it occupies a small memory footprint, IE you should be able to store more world information in an AVL tree and access it faster than most other methods. You can store points, or heights, or a key to a sprite etc.

Say you had a long list of entities to sort through and had to decide which a player could see first. If the entities were stored in a binary tree like an AVL tree, that was sorted, then you could quickly walk the tree and pull the enemies a player can see for drawing without much overhead.

No video yet? Sounds cool!

This book is gold if you can get hold of it
Tricks of the Game-Programming Gurus
Has sections on Raycasters and sprite scaling.