* @see #distribute
* @see #notifyError(Throwable)
*/
public final void showLogo() {
this.hideCursor();
SystemTimer dummyTimer = new SystemTimer();
dummyTimer.setFPS(20);
this.bsInput.refresh();
// loading GTGE logo for splash screen
BufferedImage logo = null;
try {
URL logoURL = com.golden.gamedev.Game.class.getResource("Game.dat");
BufferedImage orig = ImageUtil.getImage(logoURL);
logo = ImageUtil.resize(orig, this.getWidth(), this.getHeight());
orig.flush();
orig = null;
}
catch (Exception e) {
this.bailOut();
}
// time to show GTGE splash screen!
// clear background with black color
// and wait for a second
try {
this.clearScreen(Color.BLACK);
Thread.sleep(1000L);
}
catch (InterruptedException e) {
}
// check for focus owner
if (!this.inFocus) {
while (!this.inFocus) {
// the game is not in focus!
Graphics2D g = this.bsGraphics.getBackBuffer();
g.setColor(Color.BLACK);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
this.renderLostFocus(g);
this.bsGraphics.flip();
try {
Thread.sleep(200);
}
catch (InterruptedException e) {
}
}
this.bsInput.refresh();
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
}
}
// gradually show (alpha blending)
float alpha = 0.0f;
dummyTimer.startTimer();
boolean firstTime = true;
while (alpha < 1.0f) {
do {
if (!this.running) {
return;
}
Graphics2D g = this.bsGraphics.getBackBuffer();
g.setColor(Color.BLACK);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
Composite old = g.getComposite();
g.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, alpha));
g.drawImage(logo, 0, 0, null);
g.setComposite(old);
} while (this.bsGraphics.flip() == false);
if (firstTime) {
// workaround for OpenGL mode
firstTime = false;
dummyTimer.refresh();
}
long elapsedTime = dummyTimer.sleep();
double increment = 0.00065 * elapsedTime;
if (increment > 0.22) {
increment = 0.22 + (increment / 6);
}
alpha += increment;
if (this.isSkip(elapsedTime)) {
this.clearScreen(Color.BLACK);
logo.flush();
logo = null;
return;
}
}
// show the shiny logo for 2500 ms :-)
do {
if (!this.running) {
return;
}
Graphics2D g = this.bsGraphics.getBackBuffer();
g.drawImage(logo, 0, 0, null);
} while (this.bsGraphics.flip() == false);
int i = 0;
while (i++ < 50) { // 50 x 50 = 2500
if (!this.running) {
return;
}
try {
Thread.sleep(50L);
}
catch (InterruptedException e) {
}
if (this.isSkip(50)) {
this.clearScreen(Color.BLACK);
logo.flush();
logo = null;
return;
}
}
// gradually disappeared
alpha = 1.0f;
dummyTimer.refresh();
while (alpha > 0.0f) {
do {
if (!this.running) {
return;
}
Graphics2D g = this.bsGraphics.getBackBuffer();
g.setColor(Color.BLACK);
g.fillRect(0, 0, this.getWidth(), this.getHeight());
Composite old = g.getComposite();
g.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, alpha));
g.drawImage(logo, 0, 0, null);
g.setComposite(old);
} while (this.bsGraphics.flip() == false);
long elapsedTime = dummyTimer.sleep();
double decrement = 0.00055 * elapsedTime;
if (decrement > 0.15) {
decrement = 0.15 + ((decrement - 0.04) / 2);
}
alpha -= decrement;
if (this.isSkip(elapsedTime)) {
this.clearScreen(Color.BLACK);
logo.flush();
logo = null;
return;
}
}
logo.flush();
logo = null;
dummyTimer.stopTimer();
dummyTimer = null;
// black wait before playing
try {
this.clearScreen(Color.BLACK);