You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.1 KiB
58 lines
2.1 KiB
#include <TFT_eSPI.h> // Include the library for the LCD screen
|
|
|
|
TFT_eSPI tft = TFT_eSPI(); // Create an instance of the library
|
|
//Constantes :
|
|
//couleurs :
|
|
#define TFT_BLACK 0x0000 /* 0, 0, 0 */
|
|
#define TFT_NAVY 0x000F /* 0, 0, 128 */
|
|
#define TFT_DARKGREEN 0x03E0 /* 0, 128, 0 */
|
|
#define TFT_DARKCYAN 0x03EF /* 0, 128, 128 */
|
|
#define TFT_MAROON 0x7800 /* 128, 0, 0 */
|
|
#define TFT_PURPLE 0x780F /* 128, 0, 128 */
|
|
#define TFT_OLIVE 0x7BE0 /* 128, 128, 0 */
|
|
#define TFT_LIGHTGREY 0xC618 /* 192, 192, 192 */
|
|
#define TFT_DARKGREY 0x7BEF /* 128, 128, 128 */
|
|
#define TFT_BLUE 0x001F /* 0, 0, 255 */
|
|
#define TFT_GREEN 0x07E0 /* 0, 255, 0 */
|
|
#define TFT_CYAN 0x07FF /* 0, 255, 255 */
|
|
#define TFT_RED 0xF800 /* 255, 0, 0 */
|
|
#define TFT_MAGENTA 0xF81F /* 255, 0, 255 */
|
|
#define TFT_YELLOW 0xFFE0 /* 255, 255, 0 */
|
|
#define TFT_WHITE 0xFFFF /* 255, 255, 255 */
|
|
#define TFT_ORANGE 0xFDA0 /* 255, 180, 0 */
|
|
#define TFT_GREENYELLOW 0xB7E0 /* 180, 255, 0 */
|
|
|
|
// Parameters for the game
|
|
String level = "Novice"; // Example for level
|
|
int score = 0; // Initial score
|
|
int timeLeft = 30; // Initial time
|
|
|
|
void setup() {
|
|
tft.begin(); // Start the screen
|
|
tft.setRotation(3); // Rotate the screen to the correct orientation
|
|
|
|
// Draw the blue banner
|
|
tft.fillRoundRect(0, 0, 320, 40, 0, TFT_BLUE);
|
|
|
|
// Set the color and size of the text
|
|
tft.setTextColor(TFT_WHITE, TFT_BLUE);
|
|
tft.setTextSize(2);
|
|
|
|
// Display the level, score and time
|
|
tft.drawString(level, 10, 10);
|
|
tft.drawString(String(score)+" pts", 160, 10);
|
|
tft.drawString(String(timeLeft), 290, 10);
|
|
}
|
|
|
|
void loop() {
|
|
// Update the score and time every second
|
|
delay(1000);
|
|
tft.fillRoundRect(0, 0, 320, 40, 0, TFT_BLUE);
|
|
tft.drawString(level, 10, 10);
|
|
tft.drawString(String(score)+" pts", 160, 10);
|
|
tft.drawString(String(timeLeft), 290, 10);
|
|
|
|
// Update the game parameters here
|
|
// ...
|
|
}
|