class Projectile { PVector position, next, velocity; Projectile(PVector pos, PVector vel) { position = pos.copy(); velocity = vel.copy(); } void move() { next = PVector.add(position, velocity); // Check if projectile is offscreen if (next.x < -PROJECTILE_RADIUS || next.x > width+PROJECTILE_RADIUS || next.y < -PROJECTILE_RADIUS || next.y > height+PROJECTILE_RADIUS) projectiles.remove(this); // Check for reflection across 'Walls' for (int i = 0; i < walls.size(); i++) reflect(this, walls.get(i)); // Reflect any other projectile across this projectile's path // for (int j = 0; j < projectiles.size(); j++) { // Projectile A = projectiles.get(j); // if (A != this) { // Wall B = new Wall(position, next); // reflect(A, B); // } // } position = next.copy(); } void show() { stroke(255); fill(255); ellipse(position.x, position.y, PROJECTILE_RADIUS*2, PROJECTILE_RADIUS*2); } }