updated to remove shots when the they hit asteroids.

updated starting asteroid status count to 1

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-04-03 13:29:59 -04:00
parent 2152cc8213
commit 2d008808c8
2 changed files with 7 additions and 2 deletions

View File

@@ -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;

View File

@@ -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);
}