Académique Documents
Professionnel Documents
Culture Documents
void drawBorder () {
// Draw a border
uint16_t width = tft.width() - 1;
uint16_t height = tft.height() - 1;
uint8_t border = 10;
tft.fillScreen(RED);
tft.fillRect(border, border, (width - border * 2), (height - border * 2), WHIT
E);
}
void turntoggle() {
if (turn == 1) {
turn = 2;
return;
}
if (turn == 2) {
turn = 1;
}
}
void catseye() {
tft.fillRect(10, 260, 96, 8, WHITE);
tft.setCursor (85, 110);
tft.setTextSize (3);
tft.setTextColor(RED);
tft.println("Draw");
mosfets++;
gameover = 1;
}
void playeronewin() {
tft.fillRect(10, 260, 96, 8, WHITE);
tft.setCursor (10, 110);
tft.setTextSize (3);
tft.setTextColor(RED);
tft.println("Player 1 win");
ponewins++;
gameover = 1;
}
void playertwowin() {
tft.fillRect(10, 260, 96, 8, WHITE);
tft.setCursor (10, 110);
tft.setTextSize (3);
tft.setTextColor(RED);
tft.println("Player 2 win");
ptwowins++;
gameover = 1;
}
void updatewins() {
tft.fillRect(94, 290, 24, 8, WHITE);
itoa (ponewins, playerone, 10);
tft.setCursor (94, 290);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println(playerone);
tft.fillRect(94, 300, 24, 8, WHITE);
itoa (ptwowins, playertwo, 10);
tft.setCursor (94, 300);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println(playertwo);
tft.fillRect(82, 310, 24, 8, WHITE);
itoa (mosfets, eyes, 10);
tft.setCursor (82, 310);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println(eyes);
}
void showturn() {
if (turn == 1) {
tft.fillRect(10, 260, 96, 8, WHITE);
tft.setCursor (10, 260);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("Player 1's turn!");
}
if (turn == 2) {
tft.fillRect(10, 260, 96, 9, WHITE);
tft.setCursor (10, 260);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("Player 2's turn!");
}
}
void drawboard() {
tft.fillScreen(WHITE);
tft.fillRect(78, 0, 4, 240, BLACK);
tft.fillRect(158, 0, 4, 240, BLACK);
tft.fillRect(0, 78, 240, 4, BLACK);
tft.fillRect(0, 158, 240, 4, BLACK);
tft.fillRect(0, 250, 240, 4, BLACK);
tft.drawRect(180, 270, 60, 50, BLACK);
tft.setCursor (196, 290);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("Reset");
showturn();
tft.setCursor (10, 290);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("Player 1 wins:");
tft.setCursor (10, 300);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("Player 2 wins:");
tft.setCursor (10, 310);
tft.setTextSize (1);
tft.setTextColor(BLACK);
tft.println("DRAW :");
updatewins();
}