-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObstacle.java
More file actions
59 lines (57 loc) · 1.48 KB
/
Obstacle.java
File metadata and controls
59 lines (57 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import java.awt.*;
// 障害物
public class Obstacle{
Image[] obstacleImg;
int kind; // 1:Destroyable, 0: Not Destroyable
int x;// x座標
int y;// y座標
int startPositionX;// 開始地点
int startPositionY;
boolean survival = false;// 生きているかどうか
int l = 48;// 辺の長さ
int hp = 0;//can see or not see
Obstacle(int x, int y, Image[] img){
this.x = x;
this.y = y;
obstacleImg = img;
}
public void move(Graphics g){// 描画
if(hp == 1){// 生きているとき
if(kind == 0){// 壊せる障害物のとき
// g.setColor(Color.gray);
// g.fillRect(x, y, l, l);
g.drawImage(obstacleImg[0], x, y, null);
}else if(kind == 1){// 壊せない障害物のとき
// g.setColor(Color.yellow);
// g.fillRect(x, y, l, l);
// g.setColor(Color.black);
// g.drawRect(x, y, l, l);
g.drawImage(obstacleImg[1], x, y, null);
}
}
}
public void create(int x, int y, int kind){// 生きている状態にする
startPositionX = x;
startPositionY = y;
this.x = x;
this.y = y;
this.kind = kind;
hp = 1;
}
public void recreate(){// 障害物を作り直す
if(survival){
x = startPositionX;
y = startPositionY;
hp = 1;
survival = false;
}
}
public void reset(){// リセット
if(hp > 0) survival = true;
hp = 0;
}
public void allReset(){// 完全にリセット
survival = false;
hp = 0;
}
}