Surrog Runner Pre-Release Beta

surrogrunnerlogo

Hello all,

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

3 Likes

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 Serial writing.

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.

1 Like

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!

1 Like

I can see quite a few obvious memory crunchers.

  • String.
  • new and delete.
  • sqrt and pow

memManageObj could change its String arguments to a user-defined enum class type (some info about enum class here).

new and 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 squaredDistance)
And x * x is cheaper than pow(x, 2).


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.

1 Like

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.

@Orlan_Rod
In order to compile and run a program with the Arduino IDE there has to be a main *.ino file wich contains the setup() and loop() methods. The *.ino file extension is basically the same as a *.cpp file. In your case that’s the main.cpp.

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:

  • Rename main.cpp to surrogrunner.ino
  • Put all your files in a directory called surrogrunner

Even Atom and PlatformIO do understand this so you will be able to continue developing in Atom.

2 Likes

@Orlan_Rod
Probably the shortest and easiest way to put it is that valid .cpp files are automatically valid .ino files,
but not vice versa due to additional preprocessing performed by the IDE.

2 Likes

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.

1 Like

Right … how do I get it?

1 Like

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:

#include “player.h”

Only those libraries in the \libraries directory can be referenced with < and >.

3 Likes

Back with another beta update.

Surrog Runner 0.6 changes.
-Removed pointers.
-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.

3 Likes

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 new and delete can only be measured at runtime).

3 Likes