package code.kalter.longflight.space; import java.io.IOException; import javax.microedition.lcdui.Graphics; /** * Космос: звёзды, планеты и фон * * @author KalterFive */ public class Space { private static Space instance; public static Space getInstance(int screenW, int screenH) throws IOException { if (instance == null) { instance = new Space(screenW, screenH); } return instance; } private final Egg egg; private final Tile tile; private final Planet planet; private final Star star; private Space(int screenW, int screenH) throws IOException { egg = new Egg("/gfx/ship/5.png", screenW, screenH); tile = new Tile("/gfx/space/background.png", screenW, screenH); planet = new Planet(screenW, screenH); star = new Star(screenW, screenH); } public void paint(Graphics graphics) { tile.paint(graphics); planet.paint(graphics); star.paint(graphics); egg.paint(graphics); } public void update() { planet.upd(); tile.upd(); star.upd(); egg.upd(); } public void activateEgg() { egg.activate(); } public void deactivateEgg() { egg.deactivate(); } }