import processing.sound.*; SoundFile chompSound; int radius = 40; float x = -radius; float speed = 0.5; void setup() { size(240, 120); ellipseMode(RADIUS); chompSound = new SoundFile(this, "pacman_chomp.mp3"); } void draw() { background(0); x += speed; // Increase the value of x if (x > width+radius) { speed = -speed; chompSound.play(); } if (x < -radius) { speed = -speed; chompSound.play(); } arc(x, 60, radius, radius, 0.52, 5.76); }