I am working on a gamebuino project.
The compiler is not reporting any errors, just saying it doesn't want to work.
//imports the SPI library (needed to communicate with Gamebuino's screen)
#include <SPI.h>
//imports the Gamebuino library
#include <Gamebuino.h>
//creates a Gamebuino object named gb
Gamebuino gb;
int character = 0;
int acc;
int dam;
int crit;
int score = 0;
int px = LCDWIDTH/2;
int py = LCDHEIGHT/2;
int randCall;
int rands[] = {1,4,18,12,14,3,16,6,20,17,2,19,5,8,7,11,9,10,13,15};
int enNum = 0;
int enX[] = {0};
int enY[] = {0};
const byte E [] PROGMEM =
{
8,8,
B11111111,
B10100101,
B10000001,
B11111111,
B00111100,
B01111111,
B00001000,
B00010100,
};
const byte W [] PROGMEM =
{
8,8,
B00101000,
B01000100,
B00111000,
B01000100,
B00111000,
B00010000,
B00010000,
B00101000,
};
const byte A[] PROGMEM =
{
8,8,
B00100000,
B00111000,
B00111100,
B00011000,
B00010010,
B01111100,
B01010000,
B00101000,
};
// the setup routine runs once when Gamebuino starts up
void setup(){
// initialize the Gamebuino object
gb.begin();
//display the main menu:
gb.titleScreen(F("Dungeon Fight"));
gb.popup(F("UP[Warrior] DOWN[Assassin]"), 100);
}
// the loop routine runs over and over again forever
void loop(){
//updates the gamebuino (the display, the sound, the auto backlight... everything)
//returns true when it's time to render a new frame (20 times/second)
if(gb.update()){
randCall++;
if(randCall==19){
randCall-=19;
}
if(gb.buttons.pressed(BTN_C)){
gb.titleScreen(F("Dungeon Fight"));
}
if(character==0){
if(gb.buttons.repeat(BTN_UP,2)){
character = 1;
acc = 12;
dam = 8;
crit = 0;
} else if(gb.buttons.repeat(BTN_DOWN,2)){
character = 2;
acc = 15;
dam = 4;
crit = 4;
}
}else{
if(character==1){
if(gb.buttons.repeat(BTN_RIGHT,2)){
px+=1;
} else if(gb.buttons.repeat(BTN_LEFT,2)){
px-=1;
}else if(gb.buttons.repeat(BTN_UP,2)){
py-=1;
}else if(gb.buttons.repeat(BTN_DOWN,2)){
py+=1;
}else if(gb.buttons.repeat(BTN_A,5)){
for(int x=0;x<enNum;x++){
for(int y=0;y<enNum;y++){
if((enX[x]>px-10)&&(enX[x]<px+10)&&(enY[y]>py-10)&&(enY[y]<py+10)){
if(rands[randCall]>=acc){
enX[x]-=(dam10);
score+=1;
}
}
}
}
}
if(character==2){
if(gb.buttons.repeat(BTN_RIGHT,2)){
px+=1;
} else if(gb.buttons.repeat(BTN_LEFT,2)){
px-=1;
}else if(gb.buttons.repeat(BTN_UP,2)){
py-=1;
}else if(gb.buttons.repeat(BTN_DOWN,2)){
py+=1;
}else if(gb.buttons.repeat(BTN_A,5)){
for(int x=0;x<enNum;x++){
for(int y=0;y<enNum;y++){
if((enX[x]>px-10)&&(enX[x]<px+10)&&(enY[y]>py-10)&&(enY[y]<py+10)){
if(rands[randCall]>=acc){
enX[x]-=(dam10);
score+=1;
if(rands[randCall]<=crit){
enX[x]-=(crit*10);
score+=1;
}
}
}
}
}
}
}
}
if(randCall == 18){
enX[enNum] = 0;
enY[enNum] = LCDWIDTH/2;
enNum += 1;
}
for(int m = 0;m<=enNum;m++){
if(enX[m]<px){
enX[m]+=2;
} else{enX[m]-=2;}
if(enY[m]<py){
enY[m]+=2;
} else{enY[m]-=2;}
}
gb.display.println(F(score));
gb.display.setColor(INVERT);
if(character==1){
gb.display.drawBitmap(px,py,W);
} else if(character==2){
gb.display.drawBitmap(px,py,A);
}
for(int m = 0;m<=enNum;m++){
gb.display.drawBitmap(enX[m],enY[m],E);
}
gb.display.setColor(GRAY);
}
}}