Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 3:bd4c7eccde17
- Parent:
- 2:c6772c5ab69d
- Child:
- 4:07aada4c8421
--- a/main.cpp Wed Jun 03 16:04:09 2020 +0000 +++ b/main.cpp Thu Jun 04 15:57:13 2020 +0000 @@ -30,11 +30,53 @@ void welcome(); +bool gameOver; +int borderW, borderH, appleX, appleY, score; +enum eDirection {STOP = 0, LEFT, RIGHT, UP, DOWN}; +eDirection dir; + + + + + +void setup() +{ + gameOver = false; + dir = STOP; + borderW = WIDTH; //Fence width and height + borderH = HEIGHT; + appleX = rand() % borderW; + appleY = rand() % borderH; + score = 0; +} + +void draw() { + lcd.clear(); + + lcd.drawRect(0,0,borderW,borderH,FILL_TRANSPARENT); + lcd.refresh(); + + } + ///////////// functions //////////////// - int main() { - // first need to initialise display +//initialise Display and gamepad +lcd.init(); +pad.leds_off(); + +setup(); +while (!gameOver) +{ + draw(); + +} + + + + /* Working on game will bring welcome screen back in + + // first need to initialise display lcd.init(); pad.leds_off(); @@ -62,6 +104,10 @@ lcd.clear(); // Easter Egg time! + pad.led(3,0); // Turn Green LEDs Off + pad.led(6,0); // + pad.led(2,1); // Turn on Amber LEDs + pad.led(5,1); // lcd.printString(" Do you need ",0,1); lcd.printString(" more time? ",0,2); lcd.printString(" Grandpa! ",0,3); @@ -70,12 +116,33 @@ //returns back to normal welcome screen lcd.clear(); + pad.led(3,1); // Turn Green LEDs On + pad.led(6,1); // + pad.led(2,0); // Turn off Amber LEDs + pad.led(5,0); // lcd.printString(" Welcome to ",0,1); lcd.printString(" Snake! ",0,2); lcd.printString(" Press Start ",0,4); lcd.refresh(); - break; //stops the loop + } + + while ( pad.start_pressed() == true) { + pad.leds_off(); + pad.led(0,1); // Only Show Red LEDS + pad.led(3,1); + + // Splash Screen Info + lcd.clear(); // we need to clear the screen first + lcd.printString(" Placeholder ",0,1); + lcd.printString(" Game Coming ",0,2); + lcd.printString(" Soon ",0,3); + lcd.printString(" :) ",0,4); + lcd.refresh(); // need to refresh display after setting pixels or writing strings + + +} */ + }