DEADSOFTWARE

License project under GNU GPL 3.
[LongFlight.git] / src / code / kalter / longflight / space / Egg.java
1 package code.kalter.longflight.space;
3 import code.kalter.longflight.Loader;
4 import code.kalter.longflight.Sprite;
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 Egg extends Sprite {
16 private boolean alive;
17 private final int maxH;
19 public Egg(String path, int screenW, int maxH) throws IOException {
20 this(Loader.getInstance().getImage(path), screenW, maxH);
21 }
23 public Egg(Image image, int screenW, int maxH) {
24 super(image, (screenW - image.getWidth()) / 2, -image.getHeight());
25 this.maxH = maxH;
26 }
28 public void paint(Graphics graph) {
29 if (alive) {
30 super.paint(graph);
31 }
32 }
34 public void upd() {
35 if (alive) {
36 moveDown(1);
37 if (getY() > maxH) {
38 deactivate();
39 }
40 }
41 }
43 public void activate() {
44 alive = true;
45 }
47 public void deactivate() {
48 alive = false;
49 setY(-image.getHeight());
50 }
51 }