-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTankDriver.java
More file actions
122 lines (109 loc) · 3.18 KB
/
TankDriver.java
File metadata and controls
122 lines (109 loc) · 3.18 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
117
118
119
120
121
122
import java.util.ArrayList;
import java.awt.Graphics;
public class TankDriver {
ArrayList<TankObjects> obj = new ArrayList<TankObjects>();
private boolean goForwardP1 = false;
private boolean goBackwardP1 = false;
private boolean spinRightP1 = false;
private boolean spinLeftP1 = false;
private boolean isFiringP1 = false;
private boolean goForwardP2 = false;
private boolean goBackwardP2 = false;
private boolean spinRightP2 = false;
private boolean spinLeftP2 = false;
private boolean isFiringP2 = false;
public void clock() {
for (int i = 0; i < obj.size(); i++) {
TankObjects tmpObj = obj.get(i);
tmpObj.clock();
}
}
public void spawnPlayer1(Graphics graphics, GameCam camera) {
for (int i = 0; i < obj.size(); i++) {
TankObjects tmpObj = obj.get(i);
if (tmpObj.xCoordinate() < camera.xCoordinate() + 481) {
tmpObj.create(graphics);
}
}
}
public void spawnPlayer2(Graphics graphics, GameCam camera) {
for (int i = 0; i < obj.size(); i++) {
TankObjects tmpObj = obj.get(i);
if (tmpObj.xCoordinate() > camera.xCoordinate() + 480) {
tmpObj.create(graphics);
}
}
}
public void createMap(Graphics graphics, int x, int y) {
for (int i = 0; i < obj.size(); i++) {
TankObjects tmpObj = obj.get(i);
tmpObj.createMini(graphics, x, y);
}
}
public void addObject(TankObjects tmpObj) {
obj.add(tmpObj);
}
public void removeObject(TankObjects tmpObj) {
obj.remove(tmpObj);
}
//movement definitions player 1
public boolean isForwardPlayer() {
return goForwardP1;
}
public boolean isBackwardPlayer() {
return goBackwardP1;
}
public boolean isRightPlayer() {
return spinRightP1;
}
public boolean isLeftPlayer() {
return spinLeftP1;
}
public boolean isFiringPlayer() {
return isFiringP1;
}
public void setForwardPlayer1(boolean goForward) {
this.goForwardP1 = goForward;
}
public void setBackwardPlayer1(boolean goBackward) {
this.goBackwardP1 = goBackward;
}
public void setRightPlayer1(boolean goRight) {
this.spinRightP1 = goRight;
}
public void setLeftPlayer1(boolean goLeft) {
this.spinLeftP1 = goLeft;
}
public void setShootPlayer1(boolean fire) {
this.isFiringP1 = fire;
}
//movement definitions for player 2
public boolean isForwardPlayer2(){return goForwardP2;}
public boolean isBackwardPlayer2() {
return goBackwardP2;
}
public boolean isRightPlayer2() {
return spinRightP2;
}
public boolean isLeftPlayer2() {
return spinLeftP2;
}
public boolean isFiringPlayer2() {
return isFiringP2;
}
public void setForwardPlayer2(boolean goForward) {
this.goForwardP2 = goForward;
}
public void setBackwardPlayer2(boolean goBackward) {
this.goBackwardP2 = goBackward;
}
public void setRightPlayer2(boolean goRight) {
this.spinRightP2 = goRight;
}
public void setLeftPlayer2(boolean goLeft) {
this.spinLeftP2 = goLeft;
}
public void setShootPlayer2(boolean fire) {
this.isFiringP2 = fire;
}
}