for example, when W A S D are pressed in quick succession and repeatedly, it sometimes lags opposite to the direction it’s going.
Vini vini;
void setup() {
fullScreen();
vini = new Vini();
}
void draw() {
background(50);
vini.display();
vini.movement();
}
void keyPressed() {
vini.keys[key] = true;
}
void keyReleased() {
vini.keys[key] = false;
}
class Vini {
float x = width/2;
float y = height/2;
float velx;
float vely;
boolean [] keys = new boolean[255];
void display() {
ellipse(x, y, 50, 50);
}
void movement() {
if (keys['w']) {
y += vely;
vely = -10;
}
if (keys['s']) {
y += vely;
vely = 10;
}
if (keys['a']) {
x += velx;
velx = -10;
}
if (keys['d']) {
x += velx;
velx = 10;
}
}
}
thanks for helping! I’m only learning how to do stuff, it’s not some serious project.