Added 2 second flash notifications.
These notifications are used to notifiy they user of 1ups or level changes Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -126,6 +126,8 @@ public class AsteroidGame extends Thread {
|
|||||||
*/
|
*/
|
||||||
for(int i = 0; i < mGameFrame.getStatusBar().getLevel(); i ++)
|
for(int i = 0; i < mGameFrame.getStatusBar().getLevel(); i ++)
|
||||||
addElement(new Asteroid(gen.nextInt(mGameFrame.getDisplayWidth()), gen.nextInt(mGameFrame.getDispalyHeight()), 1, 10, 50, 3, 3, this));
|
addElement(new Asteroid(gen.nextInt(mGameFrame.getDisplayWidth()), gen.nextInt(mGameFrame.getDispalyHeight()), 1, 10, 50, 3, 3, this));
|
||||||
|
|
||||||
|
notification("Level "+ mGameFrame.getStatusBar().getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,6 +159,30 @@ public class AsteroidGame extends Thread {
|
|||||||
initLevel();
|
initLevel();
|
||||||
|
|
||||||
startGame();
|
startGame();
|
||||||
|
|
||||||
|
notification("Level "+ mGameFrame.getStatusBar().getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a nofication to the user for 2 seconds
|
||||||
|
* @param string
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private void notification(final String string) {
|
||||||
|
mGameFrame.setDisplayText(string);
|
||||||
|
|
||||||
|
new Thread(new Runnable(){
|
||||||
|
@Override
|
||||||
|
public void run(){
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(isStarted)
|
||||||
|
mGameFrame.setDisplayText(null);
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -238,6 +264,8 @@ public class AsteroidGame extends Thread {
|
|||||||
if(!hasOneUped){
|
if(!hasOneUped){
|
||||||
mGameFrame.getStatusBar().incrementShipCount();
|
mGameFrame.getStatusBar().incrementShipCount();
|
||||||
hasOneUped = true;
|
hasOneUped = true;
|
||||||
|
|
||||||
|
notification("1up!");
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
hasOneUped = false;
|
hasOneUped = false;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ public class Main {
|
|||||||
public Main() {
|
public Main() {
|
||||||
AsteroidGame game = new AsteroidGame();
|
AsteroidGame game = new AsteroidGame();
|
||||||
game.newGame();
|
game.newGame();
|
||||||
game.startGame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user