add key_action

This commit is contained in:
2023-10-09 08:25:40 +02:00
parent f933a9f7fe
commit ee50fc0348
3 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
int x = 0;//Position x
int y = 0;//Positon y
void setup () {
size(300, 300);
//Startposition Mitte
x = width /2;
y = height /2;
}
void draw () {
background(255);
ellipse(x, y, 40, 40);
}
void keyPressed() {
if (keyCode == RIGHT) {
x +=10; // Kreis nach rechts
} else if (keyCode == LEFT) {
x -= 10; // Kreis nach links
} else if (keyCode == DOWN) {
y +=10; // Kreis nach unten
} else if (keyCode == UP) {
y -= 10; // Kreis nach oben
}
}