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:
@@ -155,6 +155,12 @@ public class Asteroid extends MovingSpaceObject implements Collider, Drawable {
|
|||||||
*/
|
*/
|
||||||
public boolean shotCollision(Shot shot) {
|
public boolean shotCollision(Shot shot) {
|
||||||
if( Math.pow(mRadius, 2) > Math.pow(shot.getX() - mX, 2) + Math.pow(shot.getY() - mY, 2)){
|
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,
|
* if there is a collsion, and there are hits left,
|
||||||
* create new astroids, and remove self
|
* 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++)
|
for(int i = 0; i < mNumberSplit; i++)
|
||||||
mGame.addElement(createSplitAsteroid(mMinVelocity, mMaxVelocity));
|
mGame.addElement(createSplitAsteroid(mMinVelocity, mMaxVelocity));
|
||||||
|
|
||||||
mGame.removeElement(this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class AsteroidGame extends Thread {
|
|||||||
addElement(new Asteroid(500, 500, 1, 10, 50, 3, 3, this));
|
addElement(new Asteroid(500, 500, 1, 10, 50, 3, 3, this));
|
||||||
mGameFrame.getStatusBar().setShipCount(3);
|
mGameFrame.getStatusBar().setShipCount(3);
|
||||||
mGameFrame.getStatusBar().setScore(0);
|
mGameFrame.getStatusBar().setScore(0);
|
||||||
mGameFrame.getStatusBar().setAsteroidCount(0);
|
mGameFrame.getStatusBar().setAsteroidCount(1);
|
||||||
mGameFrame.getStatusBar().setTime(0);
|
mGameFrame.getStatusBar().setTime(0);
|
||||||
mGameFrame.getStatusBar().setShotCount(0);
|
mGameFrame.getStatusBar().setShotCount(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user