-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBullet.java
57 lines (47 loc) · 877 Bytes
/
Bullet.java
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
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
public class Bullet {
public Transform transform = new Transform(0, 0);
private int direction = 0;
//public Tank shooter;
public Bullet(int x, int y, int dir)//, Tank shooter)
{
transform.x = x;
transform.y = y;
direction = dir;
//this.shooter = shooter;
}
public void move()
{
switch(direction){
case 0:
transform.x += 5;
break;
case 1:
transform.y -= 5;
break;
case 2:
transform.x -= 5;
break;
case 3:
transform.y +=5;
break;
}
}
public void draw(Graphics g)
{
g.setColor(Color.blue);
g.fillOval(transform.x, transform.y, 10, 10);
}
public int getX()
{
return transform.x;
}
public int getY()
{
return transform.y;
}
}