Jumping Snake


(Markus Geiger) #1

Hello!

tonight I finished my first game for Arduboy. :blush:
You play a little jumping snake starting with easy levels but getting realy tuff later on :wink:
I have quite no experience with Arduboy programming but it seems to run stable, theres even some free space to add more levels.

I wish you a lot of fun and looking forward to get any kind of feedback.
You can download it right here, I´ll try to create a Github account soon, just have no experience with that kind of stuff and have to go to work right now :blue_car:

direct as .ino file:
http://www.freakwave.de/down/JumpingSnake.ino
as zip file:
http://www.freakwave.de/down/JumpingSnake.zip

Markus alias Rayjunx


Classic SNAKE
(Kevin) #2

Hook us up with a screen shot! :smiley:


(Markus Geiger) #3


(Markus Geiger) #4


(Simon) #5

43%20pm. 56%20pm

07%20pm. 18%20pm

How do you jump from one side to another?

And before another member tells you, the Arduboy library has been superseded and has been replaced by the Arduboy2 library.


(Scott R) #6

You can use @FManga’s ProjectABE to generate an animated gameplay .GIF by pressing the “R” key.

Or if you enable the serial monitor you can use @crait’s Arduboy Manager to generate screenshots.


(Simon) #7

Or simavr-arduboy, like I did!


(Scott R) #8

There’s also a capable Android app but I’m installing an OS on PC so being lazy with links :stuck_out_tongue:


(Markus Geiger) #9

Theres only direction keys to change direction and B to jump. No further instructions at the moment.


(Scott) #10

I suggest you switch to using the Arduboy2 library. The original Arduboy library is no longer being maintained. Arduboy2 is recommended for new game development. This will free up more program space (for more levels if you wish).

To do this for your game you just have to make sure the Arduboy2 library is installed and change

#include <Arduboy.h>

Arduboy arduboy;

to

#include <Arduboy2.h>

Arduboy2 arduboy;

I also suggest you add the F() macro to all of your arduboy.print() calls that print a fixed string. The F() macro allows the string to exist only in program memory instead of the compiler needing to create a copy in RAM. This will save RAM space and, for your game, will eliminate the
Low memory available, stability problems may occur.
warning that you get.

For example:
Change

arduboy.print("PRESS ANY KEY");

to

arduboy.print(F("PRESS ANY KEY"));

The Arduboy2 library provides the digitalWriteRGB() functions to control the RGB LED digitally. You can use these instead of the digitalWrite() calls, which will save a fair amount of program memory. You also don’t need to use the pinMode() functions, the library will set the RGB LED pins properly.

For example:
Change:

digitalWrite(RED_LED, LOW);

to

arduboy.digitalWriteRGB(RED_LED, RGB_ON);

There’s also the three parameter version of digitalWriteRGB(), which will set all three LEDs at the same time, so

digitalWrite(RED_LED, HIGH);
digitalWrite(GREEN_LED, HIGH);
digitalWrite(BLUE_LED, LOW);

can become

arduboy.digitalWriteRGB(RGB_OFF, RGB_OFF, RGB_ON);

At the end of setup() you have

  Serial.begin(9600);
  Serial.print("\n\n Arduboy launched \n\n");

that you were using for debugging. You can comment these lines out in the released version, to save some program space.


I didn’t look at the cause, but your game creates some compiler warnings when “verbose warnings” is turned on. You may wish to address these warnings

To see them, from the IDE menus select
File > Preferences
and then set the checkbox for
Show verbose output during: compilation

(You don’t have to worry about the warnings related to EEPROM.)


I made the above changes to your game and saved 2498 bytes of program memory and 501 bytes of RAM.

I put my version in a GitHub Gist (I may delete it at some point in the future, so the following link might be broken)


(Markus Geiger) #11

Wow! Thank you MLXXXp! and all the others!
Im now back from work and after bringing the kids into the bed found some time to check your reply. Thats awesome. I checked every point, guess I do the most things that “old” way because I was using old examples for Arduboy programming. Now it performs bether, thanks for the free space!
Now I just have to find out if some people like to play it a lot :grinning:
Is there some need for designing new levels?


(Scott) #12

Unfortunately, @crait’s tutorial series, which is often referred to for beginners looking to write Arduboy programs, uses the Arduboy library instead of Arduboy2. It would be nice if these articles were updated, or at least have some kind of note posted at the start of each topic.