package graphic; import processing.core.*; public class Bullet { PApplet p; PVector pos, vel; //PVector to store position and velocity valuse int radius = 2; // constant radius of bullet factor Bullet (PApplet p, PVector pos, PVector vel) { this.p = p; this.pos = pos; this.vel = vel; } boolean collision(Moving other) { if ( p.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 p.fill(255, 0, 128); p.ellipse(pos.x, pos.y, radius * 2, radius * 2); } }