Since the Arduboy has a speaker, I came up with a way to add sound to the game. The number of live cells for a generation is counted to determine the frequency of the tone played. The more cells, the higher the pitch. The frequency in Hz will be live cells * 3 + 20. This gives an interesting (or maybe somewhat annoying) sound pattern
NOTE: This sketch double buffers the display image and therefore uses a large amount of RAM. It’s likely to be affected by a bootloader conflict problem. If you have trouble loading new sketches after uploading ArduboyLife, see this post further down in this topic:
Looks great. Love how the opening titles become the seed!
Any chance when paused, that the direction pad + ‘Run’ button let you draw / push pixels to the screen? Alternatively I guess, you could interact with the running game and then adjust settings when paused?
I thought about doing a grid editor but don’t really have the time right now. Anyone else is welcome to take a shot at it.
The way I would do it would be to change the Up and Down buttons to not just simply toggle the sound but bring up a menu instead. The menu would allow you to toggle sound, as before, but also have options for starting an editor, perhaps saving games, etc.
My idea for an editor would be to have the D-pad move a cursor. An auto-repeat when the movement buttons were held down would be nice. The A button would toggle pixels to their opposite state and could be held down and used with the D-pad to draw lines. The B button would exit the editor.
The only problem I see is that the screen is so tiny that some may have difficulty drawing specific patterns.
I’ve also thought about being able to upload grids using USB serial (although if you have a computer that can edit grids for upload, you could probably play the game on it, making the Arduboy redundant). For upload I would have the main loop check for serial data when in pause mode. If a 0xFF was received it would signal start of data. The grid data would just be pairs of bytes containing the X and Y coordinates of each pixel, in binary. Another 0xFF would signal the end of data. The grid would be cleared and the uploaded pixels would be set. If a timeout occurred before the ending 0xFF was received, all data would be discarded. If you wanted to get fancy, you could include some kind of a checksum with the data and have the Arduboy send an ACK or NAK.
Note that because of the way the restart function is currently implemented, it couldn’t be used with the edit or upload functions.
About saving games: There obviously wouldn’t be space to save actual grid patterns, but the pseudo-random starting pattern for a game is determined by the seed passed to the genGrid() function. You could save a desired game, for retrieval and replay, by just saving the 4 byte seed, which is stored in the randSeed variable.
When I complied the game it asked me if I wanted to create a folder which I replied yes. Now every time I compile a game it finishes and restarts the unit but its always the Life demo. I complied several games before this and they all worked. So I was just wondering what I need to do to remove the life demo and install new games.
Sorry hope that makes it clearer, and thanks for any help you can offer
Try holding down the UP button when powering up and plugging in your Arduboy. This will enter “flashlight” mode and the RGB LED will light up white and the display will remain blank. (If you have one of the later Kickstarter Arduboys, with the RGB LED installation problem then the RGB LED will not turn on, but if the display remains blank then you’re probably in “flashlight” mode.) See if you can then load a new sketch.
Thanks that worked. I really appreciate the response my son is 10 and he loves the Arduboy, nice to see him enjoy something other than Minecraft. I got this as a project so we can both learn code together
I’ve converted the game to use the BeepPin1 class included in the Arduboy2 library for sounds, instead of the ArduboyTones library. This reduced the size of both program memory and RAM, and also speeds it up slightly on speed 9 with sound enabled.
The repository now has a binaries directory containing a .arduboy file (which contains a compiled ArduboyLife.hex file).
It would just be extracting the .hex anyway though.
If using a .arduboy instead of a .hex offered the ability to view some of the information stored in the info.json or use some of the embedded images then it would make more sense to use .arduboy,
but since it doesn’t, it makes no difference either way.