| C:\eclipse\workspace\Epsilon_01\src\GameSprite.java |
1
2
3
4
5
6
7
8
9
10
11
12
13 import javax.microedition.lcdui.*;
14
15 class GameSprite {
16
17 public int x;
18 public int y;
19
20 public int w;
21 public int h;
22
23 public int vx;
24 public int vy;
25
26 public byte energy;
27 public byte energyMax;
28
29 public Image img;
30
31 GameSprite(Image loaded_image, byte energy_max)
32 {
33 img = loaded_image;
34 w = loaded_image.getWidth();
35 h = loaded_image.getHeight();
36 vx = 4;
37 vy = 4;
38 energyMax = energy_max;
39 energy = energyMax;
40 }
41
42 public boolean collidesWith(GameSprite sprite)
43 {
44 return (x+w > sprite.x) && (x < sprite.x + sprite.w) &&
45 (y+h > sprite.y) && (y < sprite.y + sprite.h);
46 }
47 }
48