package code.kalter.longflight.space; import code.kalter.longflight.Loader; import code.kalter.longflight.LongFlight; import java.io.IOException; import javax.microedition.lcdui.Graphics; import javax.microedition.lcdui.Image; /** * Тайловый фон * * @author KalterFive */ class Tile { private final Image tile; private final int screenW; private final int screenH; private final int widthOfTile; private final int heightOfTile; private int positionY; public Tile(Image tile, int screenW, int screenH) { this.tile = tile; this.screenW = screenW; this.screenH = screenH; this.widthOfTile = tile.getWidth(); this.heightOfTile = tile.getHeight(); this.positionY = -128; } public Tile(String path, int screenW, int screenH) throws IOException { this(Loader.getInstance().getImage(path), screenW, screenH); } public void paint(Graphics graph) { for (int x = 0; x < screenW; x += widthOfTile) { for (int y = positionY; y < screenH; y += heightOfTile) { graph.drawImage(tile, x, y, 0); } } } public void upd() { if ((positionY++) > 0) { positionY = -128; } } }