/*
Ziele:
-Bretter werden radom eingefügt.(in erreichbarer Höhe)
-3 Plattformen random
-Game Over abfragen
-Counter ergibt sich aus besprungenen Brettern.
Bonus:
-Counter
-Highscore
-Nudelwahl / Menü
Displaygroeßen:
240 x 320 pixels
*****************************************************************************/
#include "Display.h"
#include "Sprites.h"
#include "Classes.h"
unsigned long systime, timestamp, timestamp1;
//Objekte erstellen:
//->(String name, byte width, byte height, int16_t xCoord, int16_t yCoord)
Noodle Penne ("Penne",30,64,120,50,nudelSprite);
//->(Name, width, heigth, xCoord, yCoord)
Board Board4 ("Board4",66,10,60,319,plattformSprite);
Board Board3 ("Board3",66,10,60,240,plattformSprite);
Board Board2 ("Board2",66,10,12,160,plattformSprite);
Board Board ("Board",66,10,120,80,plattformSprite);
//Button: (Name, Pinnummer)
Button LEFT ("LEFT",5);
Button RIGHT ("RIGHT",3);
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(A0));
tft.begin();
tft.setRotation(0);
Serial.println("Welcome to NoodleJump Demo");
Serial.println("*** Use arrow keys on your keyboard to navigate the Noodle. ***");
// Draw border and text
tft.drawRect(0, 0, tft.width(), tft.height(), tft.color565(80, 80, 80));
tft.setTextColor(ILI9341_RED);
tft.setTextSize(1);
tft.setCursor(120, 20);
// tft.print("Noodle Jump");
tft.setTextColor(ILI9341_WHITE);
//tft.println(" Demo");
}
void loop() {
systime = millis();
/*
Board Board("Board",66,10,XPosBrett,YPosBrett,plattformSprite);
if (systime - timestamp >= 30) {
timestamp = systime;
// Penne.jump();
YPosBrett++;
Board.drawSprite();
}
if (YPosBrett == 320){
YPosBrett = 0;
XPosBrett = random(0,174);
}
*/
Board.move(systime);
Board2.move(systime);
Board3.move(systime);
Board4.move(systime);
//Board.drawSprite();
Penne.jump(systime);
if (systime - timestamp >= 500) {
Penne.checkCollision(Board.getYCoord(),Board.getXCoord());
Penne.checkCollision(Board2.getYCoord(), Board.getXCoord());
Penne.checkCollision(Board3.getYCoord(),Board.getXCoord());
Penne.checkCollision(Board4.getYCoord(),Board.getXCoord());
timestamp = systime;
//Testi.drawSprite();
//Board.drawSprite();
}
if (systime - timestamp1 >= 50) {
LEFT.readButton();
RIGHT.readButton();
}
if (systime - timestamp1 >= 50) {
timestamp1 = systime;
if (LEFT.getStatus()){
Penne.setPosition(-10);
}
if (RIGHT.getStatus()){
Penne.setPosition(10);
}
}
}