1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <Esplora.h>
#include <TFT.h>
#include <SPI.h>
int xPos;
int yPos=EsploraTFT.height()/2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
EsploraTFT.begin();
// Met l'écran en noir
EsploraTFT.background(0,0,0);
// Met le carré en blanc
EsploraTFT.fill(255,255,255);
}
void loop() {
int depx = Esplora.readJoystickX();
int depy = Esplora.readJoystickY();
// Initialisation du snake sur l'écran
EsploraTFT.rect(xPos, yPos,4,4 );
// Fait avancer la moto d'une vitesse initial
xPos=xPos+1;
// Le dirige vers le bas
if(depy>128){
xPos=xPos-1;
yPos=yPos+1;
}
delay(100);
} |
Partager