-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWildling.java
More file actions
116 lines (98 loc) · 1.6 KB
/
Wildling.java
File metadata and controls
116 lines (98 loc) · 1.6 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.awt.Rectangle;
public class Wildling extends Entity
{
protected int wx,wy;
protected Sprite sprite;
int start_pos,final_right,final_left;
boolean left=false,right=true;
int count=0,c=5;
public Wildling(int x,int y)
{
wx=x;
wy=y;
start_pos=x;
final_right=start_pos+(16*1);
final_left=start_pos-(16*4);
sprite=Sprite.jump;
}
public void update()
{
if(wx<final_right&&!left)
{
right=true;
}
if(right)
{
if(wx<final_right)
{
wx++;
if(c>750)
c=0;
else
c++;
if(c%20==0)
{
if(count>750)
count=0;
else
count++;
if(count%2==0)
sprite=Sprite.jump1;
else
sprite=Sprite.jump;
}
}
}
if(left)
{
if(wx>final_left)
wx--;
if(c>750)
c=0;
else
c++;
if(c%20==0)
{
if(count>750)
count=0;
else
count++;
if(count%2==0)
sprite=Sprite.jump2;
else
sprite=Sprite.jump3;
}
}
if(wx==final_right)
{
left=true;
right=false;
}
if(wx==final_left)
{
left=false;
right=true;
}
clear();
}
public void render(Screen screen)
{
screen.renderTile(wx, wy, sprite);
}
public Rectangle draw_top()
{
return new Rectangle(wx,wy,16,16);
}
public Rectangle draw_rest()
{
return new Rectangle(wx,wy,16,16);
}
public void clear()
{
for(int i=0;i<level.wildling.size();i++)
{
Wildling f=level.wildling.get(i);
if(f.isRemoved())level.wildling.remove(i);
}
}
}