#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include <XPT2046_Touchscreen.h> // Library for the touch controller
// Define pins based on the table above
#define TFT_CS 5
#define TFT_DC 2
#define TFT_RST 4
#define TOUCH_CS 21
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
XPT2046_Touchscreen ts(TOUCH_CS);
int birdY = 120;
int birdVelocity = 0;
int gravity = 1;
int score = 0;
void setup() {
tft.begin();
tft.setRotation(1); // Landscape mode
ts.begin();
tft.fillScreen(ILI9341_BLUE);
}
void loop() {
// Check for touch (Jump)
if (ts.touched()) {
birdVelocity = -8; // Make the bird "flap" up
}
// Physics logic
birdVelocity += gravity;
birdY += birdVelocity;
// Simple Drawing (Bird and Background)
tft.fillScreen(ILI9341_BLUE);
tft.fillCircle(50, birdY, 10, ILI9341_YELLOW); // The Bird
// Game Over check
if (birdY > 240 || birdY < 0) {
tft.setCursor(80, 100);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(3);
tft.print("GAME OVER");
while(1); // Stop game
}
delay(30); // Control game speed
}