diff --git a/Asteroids/src/com/RickBarrette/asteroids/Asteroid.java b/Asteroids/src/com/RickBarrette/asteroids/Asteroid.java index 608575f..e5a1e57 100644 --- a/Asteroids/src/com/RickBarrette/asteroids/Asteroid.java +++ b/Asteroids/src/com/RickBarrette/asteroids/Asteroid.java @@ -155,6 +155,12 @@ public class Asteroid extends MovingSpaceObject implements Collider, Drawable { */ public boolean shotCollision(Shot shot) { if( Math.pow(mRadius, 2) > Math.pow(shot.getX() - mX, 2) + Math.pow(shot.getY() - mY, 2)){ + /** + * remove the asteroid and the shot + */ + mGame.removeElement(this); + mGame.removeElement(shot); + /* * if there is a collsion, and there are hits left, * create new astroids, and remove self @@ -163,7 +169,6 @@ public class Asteroid extends MovingSpaceObject implements Collider, Drawable { for(int i = 0; i < mNumberSplit; i++) mGame.addElement(createSplitAsteroid(mMinVelocity, mMaxVelocity)); - mGame.removeElement(this); return true; } return false; diff --git a/Asteroids/src/com/RickBarrette/asteroids/AsteroidGame.java b/Asteroids/src/com/RickBarrette/asteroids/AsteroidGame.java index 6deeea8..3d71344 100644 --- a/Asteroids/src/com/RickBarrette/asteroids/AsteroidGame.java +++ b/Asteroids/src/com/RickBarrette/asteroids/AsteroidGame.java @@ -69,7 +69,7 @@ public class AsteroidGame extends Thread { addElement(new Asteroid(500, 500, 1, 10, 50, 3, 3, this)); mGameFrame.getStatusBar().setShipCount(3); mGameFrame.getStatusBar().setScore(0); - mGameFrame.getStatusBar().setAsteroidCount(0); + mGameFrame.getStatusBar().setAsteroidCount(1); mGameFrame.getStatusBar().setTime(0); mGameFrame.getStatusBar().setShotCount(0); }