-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBall.java
More file actions
66 lines (57 loc) · 1.08 KB
/
Ball.java
File metadata and controls
66 lines (57 loc) · 1.08 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
import java.awt.Rectangle;
public class Ball extends Entity
{
protected int x, y;
protected Sprite sprite;
public Ball(int x,int y)
{
// TODO Auto-generated constructor stub
this.x=x;
this.y=y;
sprite=Sprite.ball;
}
public void update()
{
y+=5;
Rectangle ball,giant;
gaint();
ball=draw_ball();
for(int i=0;i<level.giant.size();i++)
{
giant=level.giant.get(i).draw_giant();
if(ball==null||giant==null)
{
}
if(ball.intersects(giant))
{
level.giant.get(i).remove();
remove();
}
}
if(level.getcollision(0, 3, x, y)) remove();
clear();
}
public void gaint()
{
for(int i=0;i<level.giant.size();i++)
{
level.giants[i]=level.giant.get(i).draw_giant();
}
}
public void render(Screen screen)
{
screen .renderTile(x, y, sprite);
}
public Rectangle draw_ball()
{
return new Rectangle(x+7,y+15,6,1);
}
public void clear()
{
for(int i=0;i<level.ball.size();i++)
{
Ball f=level.ball.get(i);
if(f.isRemoved())level.ball.remove(i);
}
}
}