//Particle colliding with background class CollidingParticle extends Particle { private BoolMap bmap; public CollidingParticle(float x,float y,float vx,float vy,color c,float w,int t,BoolMap m) {super(x,y,vx,vy,c,w,t); bmap = m; super.typeString = "CollidingParticle";} public void update() { if(bmap.getvalue((int)super.xpos,(int)super.ypos)) {//Collision if(!bmap.getvalue((int)super.xpos+1,(int)super.ypos)) { super.xvel = -super.xvel; } else if(!bmap.getvalue((int)super.xpos-1,(int)super.ypos)) { super.xvel = -super.xvel; } else if(!bmap.getvalue((int)super.xpos,(int)super.ypos+1) ) { super.yvel = -super.yvel; } else { super.yvel = -super.yvel; } super.yvel = super.yvel*0.7; super.xvel = super.xvel*0.7; } super.update(); } }