-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShot.java
49 lines (43 loc) · 1.04 KB
/
Shot.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
package Tank_Big_War;
public class Shot implements Runnable {
int x;
int y;
int direct;
boolean flag = true;
public Shot(){
}
public Shot(int x,int y,int direct) {
this.x = x;
this.y = y;
this.direct = direct;
}
int speed = 10;
@Override
public void run() {
while(true){
switch (direct){
case 0:
y-=speed;
break;
case 1:
x+=speed;
break;
case 2:
y+=speed;
break;
case 3:
x-=speed;
break;
}
try{
Thread.sleep(50);
}catch (InterruptedException e){
}
System.out.println("x = "+x+", y = "+y);
if(!(x>0&&x<1000&&y>0&&y<750&&flag)){
flag = false;
break;
}
}
}
}