Slade
February 12, 2017, 4:48am
#1
Hi,
I ported Stephanie Maks’ SFCave game. Details can be found on the Github page:
Original thread: https://forums.adafruit.com/viewtopic.php?f=25&t=31658
Original video: https://vimeo.com/47023779
Arduboy Pictures
Arduboy Video
https://youtu.be/dNCMg_SFuVY
3 Likes
phil8715
(Phil Graham)
February 14, 2017, 2:17pm
#2
Brilliant game. I’ve got on my Arduboy at the moment.
Slade
February 14, 2017, 8:41pm
#3
I’m glad you like it.
We should all be thanking Stephanie for writing it in the first place. And probably thanking the Arduino platform for being so easy to move between hardware. It took around 30 minutes to port across and tweak. Although I think it’s possibly still a little too fast compared to the original.
phil8715
(Phil Graham)
February 16, 2017, 4:28pm
#4
I just wish it saved high scores.
Slade
February 17, 2017, 7:13am
#5
I’ve updated the code to include a simple eeprom save. It’s somewhat dirty in that it just writes to the very beginning of the eeprom space and doesn’t care if there is data there. It also reads back the same data, but I cleared my eeprom before hand, so if you have data in the same spot, it may well read too much info back in.
There needs to be a much easier way to handle the eeprom.
Something along the lines of
write (data, length)
and
read (data,length)
Get / Put work in that fashion, but there’s no way to check to see the space is free. Which makes me wonder why there isn’t a
findfreespace() command ? It returns the beginning of the free space and the size of the chunk.
I’m rambling now Enjoy the game with saved high scores.
Dreamer3
(Josh Goebel)
February 17, 2017, 7:22am
#6
Slade:
write (data, length)
and
read (data,length)
You could implement both of these yourself easily with a for loop. Of course they still need to take an EEPROM address. The whole issue of free vs used is a whole other can of worms… but just writing an object to EEPROM should be pretty trivial.
Have to try this. Was always my favorite of the one button games like this.
phil8715
(Phil Graham)
February 17, 2017, 11:11am
#8
When I try to install the ino 2 file it comes up as a board error.
Always give full details of errors please. They give important information that will allow us to assist you.
1 Like
phil8715
(Phil Graham)
February 17, 2017, 2:54pm
#10
Arduino: 1.8.1 (Windows 10), Board: "Arduino Leonardo"
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:32:10: error: redefinition of 'Arduboy2 ab'
Arduboy2 ab;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:31:10: note: 'Arduboy2 ab' previously declared here
Arduboy2 ab;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:35:14: error: redefinition of 'unsigned int sfcScore'
unsigned int sfcScore = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:33:14: note: 'unsigned int sfcScore' previously defined here
unsigned int sfcScore = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:36:14: error: redefinition of 'unsigned int sfcHighScore'
unsigned int sfcHighScore = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:34:14: note: 'unsigned int sfcHighScore' previously defined here
unsigned int sfcHighScore = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:37:20: error: redefinition of 'char sfcWalls [32][2]'
char sfcWalls[32][2];
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:35:6: note: 'char sfcWalls [32][2]' previously declared here
char sfcWalls[32][2];
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:38:18: error: redefinition of 'char sfcRibbon [16]'
char sfcRibbon[16];
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:36:6: note: 'char sfcRibbon [16]' previously declared here
char sfcRibbon[16];
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:39:6: error: redefinition of 'char sfcTrend'
char sfcTrend = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:37:6: note: 'char sfcTrend' previously defined here
char sfcTrend = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:40:6: error: redefinition of 'char sfcVelocity'
char sfcVelocity = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:38:6: note: 'char sfcVelocity' previously defined here
char sfcVelocity = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:41:6: error: redefinition of 'char sfcWidth'
char sfcWidth = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:39:6: note: 'char sfcWidth' previously defined here
char sfcWidth = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:42:6: error: redefinition of 'char sfcMode'
char sfcMode = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:40:6: note: 'char sfcMode' previously defined here
char sfcMode = 0;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:43:9: error: redefinition of 'boolean sfcWinner'
boolean sfcWinner = false;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:41:9: note: 'boolean sfcWinner' previously defined here
boolean sfcWinner = false;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:44:9: error: redefinition of 'boolean buttonPressed'
boolean buttonPressed = false;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:42:9: note: 'boolean buttonPressed' previously defined here
boolean buttonPressed = false;
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void sfcDrawPixel(int, int, boolean)':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:48:6: error: redefinition of 'void sfcDrawPixel(int, int, boolean)'
void sfcDrawPixel(int x, int y, boolean n) {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:45:6: note: 'void sfcDrawPixel(int, int, boolean)' previously defined here
void sfcDrawPixel(int x, int y, boolean n) {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void sfcPaintScreen()':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:74:6: error: redefinition of 'void sfcPaintScreen()'
void sfcPaintScreen() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:71:6: note: 'void sfcPaintScreen()' previously defined here
void sfcPaintScreen() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'char sfcStepWalls(char)':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:162:6: error: redefinition of 'char sfcStepWalls(char)'
char sfcStepWalls(char lastValue) {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:159:6: note: 'char sfcStepWalls(char)' previously defined here
char sfcStepWalls(char lastValue) {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void sfcWallsInit()':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:176:6: error: redefinition of 'void sfcWallsInit()'
void sfcWallsInit() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:173:6: note: 'void sfcWallsInit()' previously defined here
void sfcWallsInit() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void sfcGamePlay()':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:202:6: error: redefinition of 'void sfcGamePlay()'
void sfcGamePlay() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:199:6: note: 'void sfcGamePlay()' previously defined here
void sfcGamePlay() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void setup()':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:259:6: error: redefinition of 'void setup()'
void setup() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:254:6: note: 'void setup()' previously defined here
void setup() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino: In function 'void loop()':
C:\Users\philg\Documents\Arduino\SFCave\SFCave (2).ino:270:6: error: redefinition of 'void loop()'
void loop() {
^
C:\Users\philg\Documents\Arduino\SFCave\SFCave.ino:263:6: note: 'void loop()' previously defined here
void loop() {
^
exit status 1
Error compiling for board Arduino Leonardo.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
MLXXXp
(Scott)
February 17, 2017, 2:59pm
#11
@phil8715 ,
You have 2 copies of SFCave.ino in the SFCave folder. The second one is named SFCave (2).ino
Delete SFCave.ino and then rename SFCave (2).ino to SFCave.ino
phil8715
(Phil Graham)
February 17, 2017, 3:12pm
#12
Great, all done, works perfectly!
Thank You @MLXXXp
MLXXXp
(Scott)
February 17, 2017, 3:13pm
#13
How do you define what free space is? EEPROM is just a 1K block of non-volatile storage that anyone can write any value to at any location.
If you want to turn that 1K block into some kind of a file system, there’s a long ongoing thread about that.
http://community.arduboy.com/t/shared-eeprom-storage-management-across-multiple-apps/125
phil8715
(Phil Graham)
February 17, 2017, 3:27pm
#14
Is there a way to reset high scores back to zero? It’s stuck at 30032.
I can only get to 500ish so far.
MLXXXp
(Scott)
February 17, 2017, 4:02pm
#15
Any sketch that saves high scores in EEPROM should include a way to reset them, SFCave included.
Hopefully @slade will add this.
Until then, this sketch should do it (I haven’t actually tested it):
#include <Arduboy2.h>
#include <EEPROM.h>
Arduboy2 arduboy;
void setup() {
arduboy.begin();
arduboy.clear();
arduboy.print("Press B + LEFT\nto reset SFCave\nhigh score");
arduboy.display();
while (!arduboy.pressed(B_BUTTON + LEFT_BUTTON)) { }
EEPROM.put(EEPROM_STORAGE_SPACE_START, (unsigned int) 0);
arduboy.print("\n\nDone!");
arduboy.display();
}
void loop() {
}
1 Like
Slade
February 18, 2017, 4:30am
#16
Ask and ye shall receive…
Just don’t ask the hard stuff.
I’ve left more semicolons out and wondered why things don’t work than I can remember. A lot of people might look down on VB.net , but it’s much easier to use than C++. Ah well, it’s good to learn new things, and I am, thanks to the Arduboy.
Ok. So I’ve added:
High Score clearing with B + Left.
Splash screen
Fixed button code. Uses the actual A button now !
1 Like