add key_action
This commit is contained in:
26
Lektion 2/Key_action/arrow_key_move/arrow_key_move.pde
Normal file
26
Lektion 2/Key_action/arrow_key_move/arrow_key_move.pde
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user