class Hero { static final float FRICTION = 0.9; static final float MAX_VEL = 1; float x; float y; float vx; float vy; float radius; Hero() { x = width / 2; y = height / 2; radius = 10; } void update() { x += vx; y += vy; vx *= FRICTION; vy *= FRICTION; if (x < 0) { // bounce x = 0; vx *= -1; } } void render() { fill(255, 0, 0); noStroke(); ellipse(x, y, radius * 2, radius * 2); } }