DEADSOFTWARE

Initial commit.
[LongFlight.git] / src / code / kalter / longflight / space / Tile.java
1 package code.kalter.longflight.space;
3 import code.kalter.longflight.Loader;
4 import code.kalter.longflight.LongFlight;
5 import java.io.IOException;
6 import javax.microedition.lcdui.Graphics;
7 import javax.microedition.lcdui.Image;
9 /**
10 * Тайловый фон
11 *
12 * @author KalterFive
13 */
14 class Tile {
16 private final Image tile;
17 private final int screenW;
18 private final int screenH;
19 private final int widthOfTile;
20 private final int heightOfTile;
21 private int positionY;
23 public Tile(Image tile, int screenW, int screenH) {
24 this.tile = tile;
25 this.screenW = screenW;
26 this.screenH = screenH;
27 this.widthOfTile = tile.getWidth();
28 this.heightOfTile = tile.getHeight();
29 this.positionY = -128;
30 }
32 public Tile(String path, int screenW, int screenH) throws IOException {
33 this(Loader.getInstance().getImage(path), screenW, screenH);
34 }
36 public void paint(Graphics graph) {
37 for (int x = 0; x < screenW; x += widthOfTile) {
38 for (int y = positionY; y < screenH; y += heightOfTile) {
39 graph.drawImage(tile, x, y, 0);
40 }
41 }
42 }
44 public void upd() {
45 if ((positionY++) > 0) {
46 positionY = -128;
47 }
48 }
49 }