[WIP] ArduSHMUP


(Robin Kirkman) #1

I am working on a SHMUP for Arduboy, and it’s getting along nicely. I have just release version 0.0.1 on github, which is ridiculously early but still playable.

To build from source you will need platformio on linux. Development happens in Eclipse.

ArduSHMUP on github

ArduSHMUP release v0.0.1

You should be able to download the firmware.hex from the github release, but I haven’t actually tried that. I just use

platformio run -t upload

to install it on the Arduboy.


(Robin Kirkman) #2

Basic game mechanics:

D-pad: move your ship
A: fire bullets
B: fire a beam

Your score is also your health meter. Each time you are hit you lose 100 points, and if you reach negative points then the game is over. For every enemy bullet you shoot down you get one point, and for every enemy ship 10 points. Firing the beam costs 50 points, but if you have 50 or fewer points then it will simply refuse to fire rather than cause a game-over. Enemies destroyed by the beam do not earn points.


(Scott) #3

The majority of people use the Arduino IDE for uploading sketches. If you want it to be available to more than a few people, I suggest you make it so it can compile in the Arduino IDE.

Also, the original Arduboy library is no longer being developed. The Arduboy2 library is recommended for new sketch development, so consider switching to it.


(Robin Kirkman) #4

Thanks for pointing me at Arduboy2, that looks helpful. As for using the Arduino IDE, I code this stuff for fun and I would rather not code it at all than be forced to use Arduino IDE. I’m distributing the compiled hex files in addition to source specifically because the setup I use is far beyond reproduction by most Arduboy users.


(Scott) #5

Then you’re pretty much locking out Mac and Linux users at this point in time, since there are no loaders available.


(Robin Kirkman) #6

If that were true than platformio itself would be unable to load the binaries it compiles. There may not be a GUI, I guess.

Either way, I’m coding this for my own entertainment and sharing it because I like to share what I do, not because I want as many people as possible to play it. If using more sophisticated tools than Arduino IDE makes it difficult for some users to load, it is at least possible. Using Arduino IDE would make it impossible for -everyone- to play the game because I wouldn’t develop it in the first place.


(Josh Goebel) #7

It’s easy to use it JUST to compile, not to code… I only ever use it just to push the “go” button… I do all my editing in another environment.


(Mike) #8

You don’t even need the GUI to compile (yes, I can’t stand it either). I use makefiles that simulate running the Arduino stuff to build. Unfortunately, I haven’t updated them to the modern Arduino stuff, so they can’t be used with Arduboy.

Is there a writeup somewhere on how to set up platformIO? If it’s really Windows only, I’ll not bother looking into it at all


(Robin Kirkman) #9
pip install platformio

and then for individual projects

platformio init --ide eclipse --board arduboy

platformio is for linux and probably OSX too.


(Mike McRoberts) #10

I use PlatformIO and create .ino files when developing for the ArduBoy. The files can be used directly on the Arduboy without needing any kind of conversion.


(Mike) #11

It’s in the brew package system for OSX.


(Robin Kirkman) #12

I have just released version 0.0.2. Github release with .hex file is here

A video of the gameplay is here

The github repo page has screenshots and controls/gameplay instructions.


(Scott) #13

Due to me running Linux and not using PlatformIO, I haven’t had time to spend the extra effort to upload the game, but looking at the screenshots and video, I personally feel that the game would probably look better white on black instead of black on white. Plus, doing so would increase battery life by a few hours.

You can try this by adding

  arduboy.invert(true);

after arduboy.begin(); in setup()


(Robin Kirkman) #14

Fair enough, and I’ve switched the development version to white on black. Also added sounds, which is neat, but I’m going to want to also add config to turn off the sounds.


(Scott) #15

If you switch to the now recommended Arduboy2 library, you can let the system audio control function handle the sound mute setting for you, so you don’t need to add code for it.

http://community.arduboy.com/t/new-game-boris-goes-skiing/3057/37


(Robin Kirkman) #16

Version 0.0.3 has just been released, which includes both the .hex file and a .arduboy file, making the game pretty easy to load with things like Arduboy Manager.

New features include selectable difficulty and selectable sound on/off, saved in eeprom.

Hold DOWN during startup to enable screen mirroring.

The game is white-on-black normally (without inversion) which should help reduce battery usage, thanks to @MLXXXp for the suggestion.


(Scott) #17

Please don’t use the reserved system area at the start of EEPROM for sketch storage. Any EEPROM used by a sketch should start at or past EEPROM_STORAGE_SPACE_START.

It’s better to use EEPROM.update() instead of EEPROM.write() to prevent unnecessary writes to EEPROM.

For sound mute handling you should use the library’s audio subclass functions. That way, the mute state will be carried over from sketch to sketch.

To test if sound is muted, use audio.enabled(). If it returns true then sound is on, otherwise it’s muted.

To set sound on, use audio.on() and use audio.off() to mute the sound. (The Arduboy2 library additionally has audio.toggle() to toggle the mute state.) None of these functions permanently save the state in EEPROM. To save the current mute state to EEPROM use audio.saveOnOff().

If you were to change your sketch to use the Arduboy2 and ArduboyTones libraries, you wouldn’t need to do mute testing yourself, as you currently are with the if(options.mute) statments. Muting would be handled automatically by just using the audio subclass functions.


(Scott) #18

I suggest you use a different method to enable screen mirroring. With the now recommended Arduboy2 library, holding buttons during startup is reserved for system boot features. begin() waits for all buttons to be released before returning.

If screen mirroring is only used occasionally, such as for creating screenshots for a .arduboy file, you could use a #define to enable it.

If you want it to be controllable without having to re-compile, perhaps look for a specific button or multiple button chord for exiting the intro screen. Or, you could add a menu option for it.


(Robin Kirkman) #19

I’ve got a feature branch trying to use Arduboy2 and ArduboyTones, but the system resets itself any time I call ArduboyTones::tone . Any idea what’s going on?


(Scott) #20

The functions in the ArduboyTones libraries are made static only to save code space. You should still create an object to call them because initialisation is done in the constructor. Your sketch is resetting because the pointer to the “sound enabled test” function passed to the constuctor has not been established.

As per the instructions in the ArduboyTones README:

After creating the Arduboy2 object, create an ArduboyTones object:

Arduboy2 arduboy;
ArduboyTones sound(arduboy.audio.enabled);

Then, where you are using
ArduboyTones::tone(...);
instead use
sound.tone(...);