-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGiant.java
More file actions
97 lines (80 loc) · 1.41 KB
/
Giant.java
File metadata and controls
97 lines (80 loc) · 1.41 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import java.awt.Rectangle;
public class Giant extends Entity
{
protected int x,y;
protected Sprite sprite;
int start_pos,final_right,final_left;
boolean left=false,right=true;
public Giant(int x,int y)
{
this.x=x-32;
this.y=y-32;
start_pos=x;
final_right=start_pos+(16*1);
final_left=start_pos-(16*4);
sprite=Sprite.ghost1;
}
public void update(int check)
{
if(x<final_right&&!left)
{
right=true;
}
if(right)
{
if(x<final_right)x++;
sprite=Sprite.ghost1;
}
if(left)
{
if(x>final_left)
x--;
sprite=Sprite.ghost2;
}
if(x==final_right)
{
left=true;
right=false;
}
if(x==final_left)
{
left=false;
right=true;
}
int dx,dy;
dx=(Math.abs(level.player_x-x));
dy=(-(level.player_y-y));
if(check==0)
{
if(dy<17)
{
if(dx<100)
{
level.giant_collision=true;
level.life-=1;
if(level.life==0)
{
level.gameover=true;
}
}
}
}
clear();
}
public Rectangle draw_giant()
{
return new Rectangle(x+16,y+32,sprite.width-16,sprite.height-32);
}
public void render(Screen screen)
{
screen.renderTile(x, y, sprite);
}
public void clear()
{
for(int i=0;i<level.giant.size();i++)
{
Giant f=level.giant.get(i);
if(f.isRemoved())level.giant.remove(i);
}
}
}