// a class for bullet of player class Bullet { PVector pos, vel; //PVector to store position and velocity valuse int radius = 2; // constant radius of bullet factor Bullet (PVector pos, PVector vel) { this.pos = pos; this.vel = vel; } boolean collision(Moving other) { if ( dist(pos.x, pos.y, other.pos.x, other.pos.y) < radius + other.radius) { hit.play(0); return true; //collision } return false; //no collision } //update the physics for the character void update() { pos.add(vel); // add velocity to position image(bulletimg, pos.x, pos.y, 20, 10); //effects of hit fill(255, 0, 128); ellipse(pos.x, pos.y, radius * 2, radius * 2); } }