- Code: Select all
#include <SPI.h>
#include <Gamebuino.h>
Gamebuino gb;
#define MENULENGTH 2
const char strHS[] PROGMEM = "Resume";
const char strGM[] PROGMEM = "Boot Loder";
const char* const menu[MENULENGTH] PROGMEM = {
strHS,
strGM,
};
const byte Man[] PROGMEM = {16,12,
0x3F,0x0,
0x4C,0x80,
0xFF,0xC0,
0x52,0x80,
0x40,0x80,
0x7F,0x80,
0x3F,0x0,
0x3F,0x0,
0x3F,0x0,
0x3F,0x0,
0x21,0x0,
0x21,0x0,
};
const byte tree[] PROGMEM = {16,16,
0x3,0xC0,
0x7,0xE0,
0xF,0xF0,
0x1F,0xF8,
0x3F,0xFC,
0x3F,0xFC,
0x1F,0xF8,
0xF,0xF0,
0x7,0xE0,
0x3,0xC0,
0x3,0xC0,
0x3,0xC0,
0x3,0xC0,
0x3,0xC0,
0x3,0xC0,
0x3,0xC0,
};
int man_x = LCDWIDTH/2;
int man_y = LCDHEIGHT/2;
int man_vx = 3;
int man_vy = 3;
int man_size = 8;
int game_level = 1;
void setup(){
gb.begin();
}
void loop(){
gb.collideBitmapBitmap(3, 3,Man, 0, 0, tree);
if(gb.update()){
gb.display.println((man_x));
gb.display.println((man_y));
gb.display.drawBitmap((man_x),(man_y),Man,NOROT,NOFLIP);
gb.display.drawBitmap(57,18,tree,NOROT,NOFLIP);
if(gb.buttons.repeat(BTN_RIGHT,2)){
man_x = man_x + man_vx;
gb.sound.playTick();
}
if(gb.buttons.repeat(BTN_LEFT,2)){
man_x = man_x - man_vx;
gb.sound.playTick();
}
if(gb.buttons.repeat(BTN_DOWN,2)){
man_y = man_y + man_vy;
gb.sound.playTick();
}
if(gb.buttons.repeat(BTN_UP,2)){
man_y = man_y - man_vy;
gb.sound.playTick();
}
if(gb.buttons.pressed(BTN_A)){
gb.popup(F("THIS IS A TEST!"), 200);
if(gb.buttons.pressed(BTN_C)){
switch(gb.menu(menu, MENULENGTH)){
case -1: //nothing selected
gb.titleScreen(F("Reocha's EPIC Game... hopefully"));
break;
case 0: //display system info
break;
case 1:
gb.changeGame();
break;
default:
break;
}
}
}
if(man_x < 0){
man_x = 0;
}
if((man_x + man_size) > LCDWIDTH){
man_x = LCDWIDTH - man_size;
}
if(man_y < 0){
man_y = 0;
}
if((man_y + man_size) > LCDHEIGHT){
game_level = LCDHEIGHT - man_size;
}
}
Thanks