We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I was working on this mini project that involves a move script. After testing out the move script with an ellipse as you can see right here: int x1 = 0; int y1 = 0; int dy1 = 0; int dx1 = 0; void setup(){ size(400,400); }
void draw(){
background(0,0,0);
x1 = x1 + dx1;
y1 = y1 + dy1;
ellipse(x1,y1, 50,50);
println(x1);
println(y1);
println(dx1);
println(dy1);
}
void keyPressed() {
if (key=='a') {
dx1=-5;
}
if (key=='d') {
dx1=5;
}
if (key=='s') {
dy1=5;
}
if (key=='w') {
dy1=-5;
}
}
//if a key is released, change dx1 or dy1 back to zero so the shape doesn't move
void keyReleased() {
if (key=='a') {
dx1=0;
}
if (key=='d') {
dx1=0;
}
if (key=='s') {
dy1=0;
}
if (key=='w') {
dy1=0;
}}
It would freeze the ellipse after pressing WASD (in that order) repeatedly. You can see this in this GIF:https://imgur.com/C3m3cMK However, after converting void keyreleased into a note, the ellipse would not stop after key release but it would not freeze after Repeatedly pressing WASD. Can someone help?
Answers
Can you please format your code?