package code.kalter.longflight.screen; import code.kalter.longflight.Loader; import code.kalter.longflight.LongFlight; import code.kalter.longflight.Sprite; import java.io.IOException; import java.util.Random; import javax.microedition.lcdui.Image; /** * Сплэш * * @author KalterFive */ public class Splash extends Screen { private final Random random; private final Sprite splash0; private final Sprite splash1; private long lastTime; public Splash() throws IOException { random = new Random(); Loader loader = Loader.getInstance(); // splash 0 Image splash0Image = loader.getImage("/gfx/splash/0.png"); int splash0X = (screenW - splash0Image.getWidth()) / 2; int splash0Y = (screenH - splash0Image.getHeight()) / 2; splash0 = new Sprite(splash0Image, splash0X, splash0Y); // splash 1 Image splash1Image = loader.getImage("/gfx/splash/1.png"); int splash1X = (screenW - splash1Image.getWidth()) / 2; int splash1Y = (screenH - splash1Image.getHeight()) / 2; splash1 = new Sprite(splash1Image, splash1X, splash1Y); } // override public void start() { lastTime = System.currentTimeMillis(); super.start(); } // override public void run() { while (getGameLoop()) { fps.process(); space.update(); space.paint(graphics); long delta = System.currentTimeMillis() - lastTime; // painting splash 0 if (delta < 4000) { splash0.paint(graphics); } // painting splash 1 if (delta > 5000) { splash1.paint(graphics); } // painting white fucking effect if ((delta > 4000) && (delta < 5000) || (delta > 9000)) { int c = random.nextInt(2) * 255; graphics.setColor((c << 16) | (c << 8) | c); graphics.fillRect(0, 0, screenW, screenH); } // set screen menu and stop painting splash if (delta > 10000) { LongFlight.link.setScreen(LongFlight.MENU); } flushGraphics(); LongFlight.link.sleep(20); fps.max(); } } }