Last active
July 19, 2021 20:38
-
-
Save JarekParal/33055a898968f53bcbdff12d64daa69c to your computer and use it in GitHub Desktop.
Napodobenina hry T-Rex Dinosaur z webového prohlížeče Google Chrome na výukové desce Logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tato hra je napadobenina hry [T-Rex Dinosaur](https://chromedino.com/) z webového prohlížeče Google Chrome. | |
// Hra se zobrazí při výpadku internetového připojení. | |
#include "Logic.hpp" | |
#include <iostream> | |
void nakresliZem() { | |
display.nakresliCaru(0, 9, 9, 9, Zluta); | |
} | |
void nakresliDinosauraNaZemi(Rgb barva_dinosaura = Zelena) { | |
display.nakresliCaru(1, 8, 1, 5, barva_dinosaura); | |
} | |
void nakresliDinosauraVeSkoku(Rgb barva_dinosaura = Zelena) { | |
display.nakresliCaru(1, 4, 1, 0, barva_dinosaura); | |
} | |
void nakresliPrekazku(int x) { | |
display.nastavBarvu(x, 8, Cervena); | |
} | |
int pozice_prekazky_x = 9; | |
void upravPoziciPrekazky() { | |
pozice_prekazky_x = pozice_prekazky_x - 1; | |
if (pozice_prekazky_x < 0) { | |
pozice_prekazky_x = 9; | |
} | |
} | |
bool dinosaurus_ve_skoku = false; | |
void logicMain() { | |
buttons.priStisku([]() {dinosaurus_ve_skoku = true;}, Up); | |
while (true) { | |
display.clear(); | |
nakresliZem(); | |
nakresliPrekazku(pozice_prekazky_x); | |
if (dinosaurus_ve_skoku) { | |
nakresliDinosauraVeSkoku(); | |
dinosaurus_ve_skoku = false; | |
} else { | |
if (pozice_prekazky_x == 1) { | |
nakresliDinosauraNaZemi(Cervena); | |
display.show(30); | |
delay(1500); | |
esp_restart(); | |
} | |
nakresliDinosauraNaZemi(); | |
} | |
upravPoziciPrekazky(); | |
display.show(30); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment