import java.awt.Rectangle; import javax.swing.ImageIcon; import java.awt.Graphics; public class Collidable extends Sprite{ int x,y,width,height; Rectangle rect; public Collidable(int x1, int y1, int w, int h, ImageIcon icon){ super(icon); x = x1; y = y1; width = w; height = h; rect = new Rectangle(x1,y1,w,h); } public void draw(Graphics g){ sprite = icon.getImage(); g.drawImage(sprite, x, y, width, height, null); } public boolean collidesWith(Collidable other) { return this.rect.intersects(other.rect); } public void onCollide(Collidable other){ return; } }