-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChain.java
More file actions
66 lines (55 loc) · 976 Bytes
/
Chain.java
File metadata and controls
66 lines (55 loc) · 976 Bytes
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
public class Chain extends Entity
{
protected int x,y;
protected Sprite sprite;
int start_pos,final_right,final_left;
boolean left=false,right=true;
protected Keyboard key;
public Chain(int x,int y)
{
this.x=x;
this.y=y;
start_pos=x;
final_right=start_pos+(16*3);
final_left=start_pos-(16*4);
sprite=Sprite.chain;
}
public void update(Keyboard key)
{
if(level.start_chain)
{
if(x<final_right&&!left)
{
right=true;
}
if(right)
{
if(x<final_right)x+=2;
}
if(left)
{
if(x>final_left)
x-=2;
}
if(x==final_right)
{
left=true;
right=false;
}
if(x==final_left)
{
left=false;
right=true;
}
if(key.w&&level.ball.size()==0&&level.giant.size()>0)
{
Ball b=new Ball(x,y);
level.addball(b);
}
}
}
public void render(Screen screen)
{
screen.renderTile(x, y, sprite);
}
}