how to stop the ellipse from moving when no key is being pressed?
PImage shrek;
float charx=0;
float chary=0;
boolean invert= false;
void setup() {
size(600, 500);
shrek= loadImage("shrek.jpg");
chary= height/2;
}
void draw() {
background(0);
color(255);
ellipse(charx, chary, 50, 50);
//invert colors
if (invert==true) {
filter(INVERT);
}
//move left with a
if (key == 'a'&&invert==false) {
charx=charx-10;
}
//move right with d
if (key == 'd'&&invert==false) {
charx=charx+10;
}
//move right with a
if (key == 'a'&&invert==true) {
charx=charx+10;
}
//move left with d
if (key == 'd'&&invert==true) {
charx=charx-10;
}
}