In the last dev log, I started the project for my little Arduboy Memory Game.
This time I have prepared the sprites for the game cards.
Storing Game Sprites
To keep track of the sprites, I created a new Sprites header file. This file holds a two-dimensional array of the sprites. I also use type alias declaration to make Sprite a synonym for unsigned int. A ‘Sprite’ it thus the index if the array where the sprite is stored.
Drawing sprites is down using the Device interface. For this I added the function ‘setSprite’ which takes a Sprite (index) and the position where the sprite should be drawn.
Finally, to test the new sprites I call the setSprite function within the loop function of the .ino file, and draw both game card squares and sprites.
Next up is creating an array to store the game board and randomly generating a level.
The source code for this project is available here on GitHub.