Decreased rotational speed, and updated AsteroidGame.downShip()

I updated AsteroidGame.downShip() to move & stop the ship, rather than
deleting the current ship and creating a new one. Ships are only
deleted when the game is over.

I added MovingSpaceObject.allStop() to complement the above.

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-04-04 09:07:00 -04:00
parent 8611bad5b8
commit c0f14c2f2e
2 changed files with 24 additions and 5 deletions

View File

@@ -66,23 +66,30 @@ public class AsteroidGame extends Thread {
private void downShip() {
System.out.println("Ship collision dected");
/*
* remove the players ship's
* move the players ship's
*/
Object o;
Object o = null;
Ship s = null;
for (int i = 0; i < mWorld.size(); i++){
o = mWorld.get(i);
if(o instanceof Ship)
mWorld.remove(i);
s = (Ship) o;
}
if(s != null){
s.setLocation(100, 100);
s.allStop();
}
mGameFrame.getStatusBar().decrementShipCount();
if(mGameFrame.getStatusBar().getShipCount() > 0){
pauseGame();
mWorld.add(new Ship(100,100,0,.35,.98,.4,1));
mGameFrame.setDisplayText("You died, You can hyper jump to a safe place now...\nPress start when ready.");
} else {
mGameFrame.setDisplayText("Game Over");
if(s != null)
mWorld.remove(s);
}
mGameFrame.repaint();
}
@@ -130,7 +137,7 @@ public class AsteroidGame extends Thread {
mGameFrame.getStatusBar().setShotCount(0);
mGameFrame.getStatusBar().setLevel(1);
mWorld.add(new Ship(100,100,0,.35,.98,.4,1));
mWorld.add(new Ship(100,100,0,.35,.98,.2,1));
initLevel();

View File

@@ -33,6 +33,18 @@ public class MovingSpaceObject extends SpaceObject implements Moveable{
protected double mAcceleration;
protected boolean isTurningLeft = false, isTurningRight = false, isAccelerating = false, isActive = true;
/**
* Completly stops the ship
* @author ricky barrette
*/
public void allStop(){
mXVelocity = 0;
mYVelocity = 0;
isTurningLeft = false;
isTurningRight = false;
isAccelerating = false;
}
/**
* @return true if the space object is accelerating
* @author ricky barrette