DEADSOFTWARE

Initial commit.
[LongFlight.git] / src / code / kalter / longflight / screen / Splash.java
1 package code.kalter.longflight.screen;
3 import code.kalter.longflight.Loader;
4 import code.kalter.longflight.LongFlight;
5 import code.kalter.longflight.Sprite;
6 import java.io.IOException;
7 import java.util.Random;
8 import javax.microedition.lcdui.Image;
10 /**
11 * Сплэш
12 *
13 * @author KalterFive
14 */
15 public class Splash extends Screen {
17 private final Random random;
18 private final Sprite splash0;
19 private final Sprite splash1;
20 private long lastTime;
22 public Splash() throws IOException {
23 random = new Random();
24 Loader loader = Loader.getInstance();
26 // splash 0
27 Image splash0Image = loader.getImage("/gfx/splash/0.png");
28 int splash0X = (screenW - splash0Image.getWidth()) / 2;
29 int splash0Y = (screenH - splash0Image.getHeight()) / 2;
30 splash0 = new Sprite(splash0Image, splash0X, splash0Y);
32 // splash 1
33 Image splash1Image = loader.getImage("/gfx/splash/1.png");
34 int splash1X = (screenW - splash1Image.getWidth()) / 2;
35 int splash1Y = (screenH - splash1Image.getHeight()) / 2;
36 splash1 = new Sprite(splash1Image, splash1X, splash1Y);
37 }
39 // override
40 public void start() {
41 lastTime = System.currentTimeMillis();
42 super.start();
43 }
45 // override
46 public void run() {
47 while (getGameLoop()) {
48 fps.process();
49 space.update();
50 space.paint(graphics);
51 long delta = System.currentTimeMillis() - lastTime;
53 // painting splash 0
54 if (delta < 4000) {
55 splash0.paint(graphics);
56 }
58 // painting splash 1
59 if (delta > 5000) {
60 splash1.paint(graphics);
61 }
63 // painting white fucking effect
64 if ((delta > 4000) && (delta < 5000) || (delta > 9000)) {
65 int c = random.nextInt(2) * 255;
66 graphics.setColor((c << 16) | (c << 8) | c);
67 graphics.fillRect(0, 0, screenW, screenH);
68 }
70 // set screen menu and stop painting splash
71 if (delta > 10000) {
72 LongFlight.link.setScreen(LongFlight.MENU);
73 }
75 flushGraphics();
76 LongFlight.link.sleep(20);
77 fps.max();
78 }
79 }
80 }