Today i present you Surrog Runner; an arcade game, where you must gather all flags, while traversing the varies rooms and exiting. Controls are: arrows to move in direction, A to increase speed, and B to decrease speed. Arrow press at edge in the direction to exit to another room. Return to starting room to find exit to next stage stairs. The faster you go, the more points you’ll get when you light up the grid. Indicator arrows on the grid, will point you to the rooms available. There is two bugs that are known, so i’m releasing this as 0.5, until i fix those. Any other bugs you find let me know so i can fix for 1.0. First time uploading, so let me know if the file works.
Note: to flash another game, you need to put it in flashlight mode.
Surrog Runner Hex
Surrog Runner Source code
Interesting, any reason why you called your hex file Firmware.hex? I only tried it in projectABE so far, will try on the actual thing later. But in the emulator it was really slow. Probably because you are using a lot of flicking to simulate the grey.
Oh, it’s because i didn’t know if it would break the hex file. This is the first time uploading a game, so didn’t want to risk it.
The slowdown happens when i have the the arduboy connected with the usb cable. The moment you unplug and turn off/on it will play normally. I think it may be that i’m using a lot of the memory. Or it could also be the effect i am doing.
Oops, looks like i forgot to set the hazard type back to normal. The correct hazard first to show is the landmine. Fixed and reuploaded.
If you posted the code instead of just the hex then we could probably tell you what the issue is.
If it slows down when the USB cable is connected, that sounds like you’re doing a lot of
Oh i see, yeah, i added in a bit of code for the screen mirroring thing in the arduboy manager, but it doesn’t work with my game for some reason. Going to remove it. Thanks.
I’ll post the source code to github soon.
Update: source code has been uploaded to github. Link is in the first post. Have a gander through the source, and let me know what i could improve on. Thanks!
I can see quite a few obvious memory crunchers.
memManageObj could change its
String arguments to a user-defined
enum class type (some info about
enum class here).
delete can be avoided by giving objects a
bool active member and storing the objects themselves instead of pointers to objects. Flipping a simple flag is much cheaper and easier to manage than dynamic allocation.
And as you’re calculating distance, if you’re only comparing distances then you can elide the
sqrt and compare the square of the distances, which will be proportionate (i.e. all comparisons that hold true for
sqrt(squaredDistance) remain true for
x * x is cheaper than
Also it’s not really important, but you manually declare constructors and destructors and then leave them empty, which kind of defeats the point of declaring them.
If they don’t do anything special you can just omit them and let the compiler fill in the blanks.
There does not apprear to be an *.ino file in your source. You might like to add that to the repo.
Where is the .ino file? I’m using the Atom editor with PlatformIO to make games.
I am not familiar with that editor however, an Arduino or Arduboy program always has a *.ino file associated with it. It would normally be in the root of your source directory.
In order to compile and run a program with the Arduino IDE there has to be a main
*.ino file wich contains the
loop() methods. The
*.ino file extension is basically the same as a
*.cpp file. In your case that’s the
The majority of our user use the Arduino IDE to run and upload games to the Arduboy.
It is not as developer friendly (clang, etc…) as Platform IO but is much simpler to use and understand for beginners.
In order to be able to run a program with the Arduino IDE, there has to be a directory with the same name as your main
*.ino file which contains all source files.
To be beginner friendly I would appreciate if you could rename you sourcefiles.
This can be simply done by:
- Put all your files in a directory called
Even Atom and PlatformIO do understand this so you will be able to continue developing in Atom.
Probably the shortest and easiest way to put it is that valid
.cpp files are automatically valid
but not vice versa due to additional preprocessing performed by the IDE.
Also, the library ‘MemoryFree’ is not in the code and I cannot find it in the Arduino Library manager. Is is a standard one or a custom library?
It is a small library only used for debugging and called MemoryUseage in the library manager. Actually it shouldn’t be even in a final release of a program since it is only taking up space.
Finally got it to run.
Another difference between PlatformIO and the Arduino IDE is that the IDE expects local includes to be in the format:
Only those libraries in the \libraries directory can be referenced with < and >.
Back with another beta update.
Surrog Runner 0.6 changes.
-Removed old/unneeded headers.
-Replaced String type with enums.
-Updated github with source in folder and changed main to .ino.
Link in first post as always.
That’s looking much better.
Now it almost certainly runs better, and probably uses less memory (which might not be obvious, because the memory used by
delete can only be measured at runtime).