daily_automated
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Buttons example"));
|
||||
gb.setFrameRate(10); //lower the FPS to have time to see what happens
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println("- BUTTONS -");
|
||||
|
||||
gb.display.print("Pressed: ");
|
||||
if(gb.buttons.pressed(BTN_A)) gb.display.print("\25");
|
||||
else gb.display.print(" ");
|
||||
if(gb.buttons.pressed(BTN_B)) gb.display.print("\26");
|
||||
else gb.display.print(" ");
|
||||
gb.display.println();
|
||||
|
||||
gb.display.print("Released:");
|
||||
if(gb.buttons.released(BTN_A)) gb.display.print("\25");
|
||||
else gb.display.print(" ");
|
||||
if(gb.buttons.released(BTN_B)) gb.display.print("\26");
|
||||
else gb.display.print(" ");
|
||||
gb.display.println();
|
||||
|
||||
gb.display.print("Held: ");
|
||||
if(gb.buttons.held(BTN_A,10)) gb.display.print("\25");
|
||||
else gb.display.print(" ");
|
||||
if(gb.buttons.held(BTN_B,10)) gb.display.print("\26");
|
||||
else gb.display.print(" ");
|
||||
gb.display.println();
|
||||
|
||||
gb.display.print("Repeat: ");
|
||||
if(gb.buttons.repeat(BTN_A,10)) gb.display.print("\25");
|
||||
else gb.display.print(" ");
|
||||
if(gb.buttons.repeat(BTN_B,10)) gb.display.print("\26");
|
||||
else gb.display.print(" ");
|
||||
gb.display.println();
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Buttons example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("timeHeld example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.print("gb.buttons.timeHeld\n\n");
|
||||
|
||||
gb.display.print("BTN_A:");
|
||||
gb.display.println(gb.buttons.timeHeld(BTN_A));
|
||||
|
||||
gb.display.print("BTN_B:");
|
||||
gb.display.println(gb.buttons.timeHeld(BTN_B));
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("timeHeld example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
static unsigned char PROGMEM logo[]=
|
||||
{
|
||||
8,8,
|
||||
B00000000,
|
||||
B00100100,
|
||||
B00011000,
|
||||
B01111110,
|
||||
B00111100,
|
||||
B01111110,
|
||||
B00111100,
|
||||
B00000000,
|
||||
};
|
||||
|
||||
void setup(){
|
||||
// initialize the Gamebuino object
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Example game"), logo);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println("Hello world");
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Example game"), logo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Count example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
int count = gb.frameCount;
|
||||
gb.display.println(count);
|
||||
|
||||
if( (count / 8) % 2 ){ //true half of the time on 8 frames
|
||||
gb.display.println(F("BLINK"));
|
||||
}
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Count example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
char name[11];
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Name example"));
|
||||
gb.getDefaultName(name);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.print("Hello ");
|
||||
gb.display.print(name);
|
||||
}
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Name example"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Update example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
while(1){ //loops forever
|
||||
if(gb.update()){ //update everything
|
||||
|
||||
//put your game here. I will run at a fixed frequency (20 times per second by default)
|
||||
gb.display.println(F("First loop"));
|
||||
gb.display.println(F("Press \25 to continue"));
|
||||
|
||||
if(gb.buttons.pressed(BTN_A)) //break out of the loop if C is pressed
|
||||
break;
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Update example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while(1){ //loops forever
|
||||
if(gb.update()){ //update everything
|
||||
|
||||
//put your game here. I will run at a fixed frequency (20 times per second by default)
|
||||
gb.display.println(F("Second loop"));
|
||||
gb.display.println(F("Press \25 to continue"));
|
||||
|
||||
if(gb.buttons.pressed(BTN_A)) //break out of the loop if C is pressed
|
||||
break;
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Update example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
//bitmap encoded using the Bitmap Encoder which can be found here : http://gamebuino.com/wiki/index.php?title=Download
|
||||
const byte pointerBitmap[] PROGMEM = {16,22,0xC,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x13,0x80,0x12,0x70,0x12,0x4C,0x12,0x4A,0xD2,0x49,0xB0,0x9,0x90,0x1,0x90,0x1,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0x2,0x10,0x2,0x10,0x2,0x8,0x4,0x8,0x4,0xF,0xFC,};
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Bitmap example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
//draw the pointer bitmap at coordinates x=0 and y=0 (top left corner)
|
||||
gb.display.drawBitmap(0, 0, pointerBitmap);
|
||||
|
||||
//draw the pointer bitmap at coordinates x=18 and y=0 with an horizontal flip
|
||||
gb.display.drawBitmap(18, 0, pointerBitmap, NOROT, FLIPH);
|
||||
|
||||
//flip value can be
|
||||
//NOFLIP : the bitmap is not flipped
|
||||
//FLIPH : flipped horizontally (like using a vertical mirror)
|
||||
//FLIPV : flipped vertically (like using an horizontal mirror)
|
||||
//FLIPVH : flipped both horizontally and vertically
|
||||
|
||||
//rotation value can be :
|
||||
//NOROT : no rotation
|
||||
//ROTCW : 90° rotation clockwise
|
||||
//ROTCCW : 90° rotation counter clockwise
|
||||
//ROT180 : half turn rotation
|
||||
|
||||
//the rotation and flipping values can be stored in bytes :
|
||||
byte rotation = NOROT;
|
||||
byte flip = NOFLIP;
|
||||
|
||||
//then you can change the rotation and flipping depending on conditions
|
||||
//here we use the buttons to rotate and flip the bitmap
|
||||
if(gb.buttons.repeat(BTN_A,1)){
|
||||
flip = FLIPH;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_B,1)){
|
||||
flip = FLIPV;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_RIGHT,1)){
|
||||
rotation = ROTCW;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_LEFT,1)){
|
||||
rotation = ROTCCW;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_DOWN,1)){
|
||||
rotation = ROT180;
|
||||
}
|
||||
|
||||
//draw the pointer bitmap at coordinates x=36 and y=0 with the rotation and flip defined above
|
||||
gb.display.drawBitmap(36, 0, pointerBitmap, rotation, flip);
|
||||
|
||||
//don't forget to allow the user to get back to the title screen when C is used :
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Bitmap example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1011 B |
@@ -0,0 +1,78 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
//bitmap encoded using the Bitmap Encoder which can be found here : http://gamebuino.com/wiki/index.php?title=Download
|
||||
const byte pointerBitmap[] PROGMEM = {16,22,0xC,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x12,0x0,0x13,0x80,0x12,0x70,0x12,0x4C,0x12,0x4A,0xD2,0x49,0xB0,0x9,0x90,0x1,0x90,0x1,0x40,0x1,0x40,0x1,0x20,0x1,0x20,0x2,0x10,0x2,0x10,0x2,0x8,0x4,0x8,0x4,0xF,0xFC,};
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Color example"));
|
||||
gb.setFrameRate(42); //set the frequency at 42 frames per second for better results with gray
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
//set the color to be use to black. If there is no second color specified, the background will be transparent
|
||||
gb.display.setColor(BLACK);
|
||||
gb.display.fillRect(34,0, 16, 48);
|
||||
|
||||
//colors available are :
|
||||
// WHITE
|
||||
// BLACK
|
||||
// INVERT : negative effect
|
||||
// GRAY : creates gray using screen's persistence by flickering the pixels quickly
|
||||
// experiments have shown that running the screen at 42 frames per second gives better results with gray
|
||||
|
||||
//the color value can be stored in a variable :
|
||||
byte color = BLACK;
|
||||
//when the background and the foreground colors are the same, the background is left transparent.
|
||||
byte background = WHITE;
|
||||
|
||||
//then you can change the color depending on conditions
|
||||
//here we use the buttons :
|
||||
if(gb.buttons.repeat(BTN_RIGHT,1)){
|
||||
color = WHITE;
|
||||
gb.display.println(F("WHITE"));
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_LEFT,1)){
|
||||
color = INVERT;
|
||||
gb.display.println(F("INVERT"));
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_DOWN,1)){
|
||||
color = GRAY;
|
||||
gb.display.println(F("GRAY"));
|
||||
}
|
||||
|
||||
//change if background color if buttons are pressed :
|
||||
if(gb.buttons.repeat(BTN_A,1)){
|
||||
background = BLACK;
|
||||
gb.display.println(F("BLACK"));
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_B,1)){
|
||||
background = INVERT;
|
||||
gb.display.println(F("INVERT"));
|
||||
}
|
||||
|
||||
//set the color defined above
|
||||
gb.display.setColor(color, background);
|
||||
|
||||
//then draw a few things :
|
||||
//a rectangle
|
||||
gb.display.fillRect(20,16,16,16);
|
||||
//a bitmap
|
||||
gb.display.drawBitmap(20, 16, pointerBitmap);
|
||||
//some text
|
||||
gb.display.cursorX = 40;
|
||||
gb.display.cursorY = 0;
|
||||
gb.display.fontSize = 2;
|
||||
gb.display.print(F("Text"));
|
||||
gb.display.fontSize = 1;
|
||||
|
||||
|
||||
//don't forget to allow the user to get back to the title screen when C is used :
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Bitmap example"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
uint8_t *displayBuffer; //pointer to store the buffer's address
|
||||
byte i = 0;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Direct display\nbuffer access"));
|
||||
//get the buffer's address and assign it to displayBuffer
|
||||
displayBuffer = gb.display.getBuffer();
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
//directly access the display's buffer value
|
||||
displayBuffer[i] = BLACK;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
// these two default fonts are already defined in the Gamebuino library
|
||||
// the "extern" modifier is used to be able to use a variable declared in another file
|
||||
extern const byte font3x3[]; //a really tiny font
|
||||
extern const byte font3x5[]; //a small but efficient font (default)
|
||||
extern const byte font5x7[]; //a large, comfy font
|
||||
|
||||
void setup(){
|
||||
// initialize the Gamebuino object
|
||||
gb.begin();
|
||||
gb.display.setFont(font5x7);
|
||||
gb.titleScreen(F("Font size"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.setFont(font3x3);
|
||||
gb.display.println(F("The quick brown fox\njumps over the doge"));
|
||||
gb.display.setFont(font3x5);
|
||||
gb.display.print("3x5 font\n");
|
||||
gb.display.fontSize = 2;
|
||||
gb.display.print("3x5 font\n");
|
||||
gb.display.fontSize = 1;
|
||||
gb.display.setFont(font5x7);
|
||||
gb.display.print("5x7 font\n");
|
||||
gb.display.fontSize = 2;
|
||||
gb.display.print("5x7 font\n");
|
||||
gb.display.fontSize = 1;
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Font size"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
char text[13] = "Default text";
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Keyword example"));
|
||||
gb.keyboard(text, 13);
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println(F("You wrote:"));
|
||||
gb.display.println(text);
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Keyword example"));
|
||||
gb.keyboard(text, 13);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
////declare all the variables needed to make a menu
|
||||
//number of items in the menu
|
||||
#define MENULENGTH 2
|
||||
//The differents strings to put in the menu
|
||||
//each string can be used in different menus
|
||||
const char strSystemInfo[] PROGMEM = "Stystem info";
|
||||
const char strChangeGame[] PROGMEM = "Change game";
|
||||
//Put all the different items together in a menu (an array of strings actually)
|
||||
const char* const menu[MENULENGTH] PROGMEM = {
|
||||
strSystemInfo,
|
||||
strChangeGame,
|
||||
};
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Menu example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
switch(gb.menu(menu, MENULENGTH)){
|
||||
case -1: //nothing selected
|
||||
gb.titleScreen(F("Menu example"));
|
||||
break;
|
||||
case 0: //display system info
|
||||
displaySystemInfo();
|
||||
break;
|
||||
case 1: //change game
|
||||
gb.changeGame();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void displaySystemInfo(){
|
||||
while(1){
|
||||
if(gb.update()){
|
||||
if (gb.buttons.pressed(BTN_C)) {
|
||||
gb.sound.playCancel();
|
||||
return;
|
||||
}
|
||||
gb.display.print(F("Bat:"));
|
||||
gb.display.print(gb.battery.voltage);
|
||||
gb.display.println(F("mV"));
|
||||
|
||||
gb.display.print(F("Bat lvl:"));
|
||||
gb.display.print(gb.battery.level);
|
||||
gb.display.println(F("/4"));
|
||||
|
||||
gb.display.print(F("Light:"));
|
||||
gb.display.println(gb.backlight.ambientLight);
|
||||
|
||||
gb.display.print(F("Backlight:"));
|
||||
gb.display.println(gb.backlight.backlightValue);
|
||||
|
||||
gb.display.print(F("Volume:"));
|
||||
gb.display.print(gb.sound.getVolume());
|
||||
gb.display.print(F("/"));
|
||||
gb.display.println(gb.sound.volumeMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("Popup example"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println("Press \25 \26 or \27\nto see a popup");
|
||||
if(gb.buttons.pressed(BTN_A))
|
||||
gb.popup(F("A pressed"),5);
|
||||
if(gb.buttons.pressed(BTN_B))
|
||||
gb.popup(F("B pressed"),5);
|
||||
if(gb.buttons.pressed(BTN_C))
|
||||
gb.popup(F("C pressed"),5);
|
||||
}
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("Popup example"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
//find the bitmap encoder at https://github.com/Rodot/BitmapEncoder
|
||||
const byte oponentBitmap[] PROGMEM = {88,48,0x0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x0,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x0,0xF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0,0x7F,0xFF,0xF0,0x0,0x7,0xFF,0xF0,0xFF,0xFF,0xFE,0x0,0x3F,0xFF,0xF0,0x0,0x3,0xFF,0xE0,0x1F,0xFF,0xFE,0x0,0x1F,0xFF,0xF0,0x0,0x0,0xFF,0xE0,0x3,0xFF,0xFC,0x0,0xF,0xFF,0xF0,0x0,0x0,0x3F,0xE0,0x1,0xFF,0xFC,0x0,0xF,0xFF,0xF0,0x0,0x0,0xF,0xE0,0x0,0xFF,0xF8,0x0,0xF,0xF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|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("collideBitmapBitmap"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println(F("Move with arrows"));
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("collideBitmapBitmap"));
|
||||
}
|
||||
|
||||
//update player
|
||||
if(gb.buttons.repeat(BTN_RIGHT,1)){
|
||||
player_x = player_x + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_LEFT,1)){
|
||||
player_x = player_x - 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_DOWN,1)){
|
||||
player_y = player_y + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_UP,1)){
|
||||
player_y = player_y - 1;
|
||||
}
|
||||
|
||||
//update collisions
|
||||
if(gb.collideBitmapBitmap(player_x, player_y, playerBitmap, oponent_x, oponent_y, oponentBitmap)){
|
||||
gb.sound.playTick();
|
||||
gb.display.print(F("Colliding"));
|
||||
}
|
||||
|
||||
//draw bitmaps
|
||||
gb.display.setColor(INVERT);
|
||||
gb.display.drawBitmap(player_x, player_y, playerBitmap);
|
||||
gb.display.drawBitmap(oponent_x, oponent_y, oponentBitmap);
|
||||
gb.display.setColor(BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
byte player_x = 20;
|
||||
byte player_y = 20;
|
||||
|
||||
byte oponent_x = LCDWIDTH/2;
|
||||
byte oponent_y = LCDHEIGHT/2;
|
||||
byte oponent_w = 17;
|
||||
byte oponent_h = 12;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("collidePointRect"));
|
||||
}
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println(F("\n Move with arrows"));
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("collidePointRect"));
|
||||
}
|
||||
|
||||
//update player
|
||||
if(gb.buttons.repeat(BTN_RIGHT,1)){
|
||||
player_x = player_x + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_LEFT,1)){
|
||||
player_x = player_x - 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_DOWN,1)){
|
||||
player_y = player_y + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_UP,1)){
|
||||
player_y = player_y - 1;
|
||||
}
|
||||
|
||||
//update collisions
|
||||
if(gb.collidePointRect(player_x, player_y, oponent_x, oponent_y, oponent_w, oponent_h)){
|
||||
gb.sound.playTick();
|
||||
gb.display.print(F(" Colliding"));
|
||||
}
|
||||
|
||||
//draw oponent
|
||||
gb.display.fillRect(oponent_x, oponent_y, oponent_w, oponent_h);
|
||||
|
||||
//draw player
|
||||
gb.display.setColor(INVERT);
|
||||
gb.display.drawPixel(player_x, player_y);
|
||||
gb.display.setColor(BLACK);
|
||||
|
||||
//draw a few lines to help seeing the pixel:
|
||||
gb.display.drawLine(0, player_y, 3, player_y);
|
||||
gb.display.drawLine(player_x, 0, player_x, 3);
|
||||
gb.display.drawLine(player_x,LCDHEIGHT-3, player_x, LCDHEIGHT);
|
||||
gb.display.drawLine(LCDWIDTH - 3, player_y, LCDWIDTH, player_y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include <SPI.h>
|
||||
#include <Gamebuino.h>
|
||||
Gamebuino gb;
|
||||
|
||||
|
||||
|
||||
byte player_x = 10;
|
||||
byte player_y = 10;
|
||||
byte player_w = 8;
|
||||
byte player_h = 16;
|
||||
|
||||
byte oponent_x = LCDWIDTH/2;
|
||||
byte oponent_y = LCDHEIGHT/2;
|
||||
byte oponent_w = 17;
|
||||
byte oponent_h = 12;
|
||||
|
||||
void setup(){
|
||||
gb.begin();
|
||||
gb.titleScreen(F("collideRectRect"));
|
||||
}
|
||||
|
||||
|
||||
void loop(){
|
||||
if(gb.update()){
|
||||
gb.display.println(F("Move with arrows"));
|
||||
|
||||
if(gb.buttons.pressed(BTN_C)){
|
||||
gb.titleScreen(F("collideRectRect"));
|
||||
}
|
||||
|
||||
//update player
|
||||
if(gb.buttons.repeat(BTN_RIGHT,1)){
|
||||
player_x = player_x + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_LEFT,1)){
|
||||
player_x = player_x - 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_DOWN,1)){
|
||||
player_y = player_y + 1;
|
||||
}
|
||||
if(gb.buttons.repeat(BTN_UP,1)){
|
||||
player_y = player_y - 1;
|
||||
}
|
||||
|
||||
//update collision
|
||||
if(gb.collideRectRect(player_x, player_y, player_w, player_h, oponent_x, oponent_y, oponent_w, oponent_h)){
|
||||
gb.sound.playTick();
|
||||
gb.display.print(F("Collliding"));
|
||||
}
|
||||
|
||||
//draw rectangles
|
||||
gb.display.setColor(INVERT);
|
||||
gb.display.fillRect(player_x, player_y, player_w, player_h);
|
||||
gb.display.fillRect(oponent_x, oponent_y, oponent_w, oponent_h);
|
||||
gb.display.setColor(BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user