-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTile.java
More file actions
144 lines (128 loc) · 3.87 KB
/
Tile.java
File metadata and controls
144 lines (128 loc) · 3.87 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import com.googlecode.lanterna.terminal.Terminal.SGR;
import com.googlecode.lanterna.TerminalFacade;
import com.googlecode.lanterna.input.Key;
import com.googlecode.lanterna.input.Key.Kind;
import com.googlecode.lanterna.terminal.Terminal;
import com.googlecode.lanterna.terminal.Terminal.Color;
import com.googlecode.lanterna.terminal.TerminalSize;
import com.googlecode.lanterna.LanternaException;
import com.googlecode.lanterna.input.CharacterPattern;
import com.googlecode.lanterna.input.InputDecoder;
import com.googlecode.lanterna.input.InputProvider;
import com.googlecode.lanterna.input.Key;
import com.googlecode.lanterna.input.KeyMappingProfile;
import java.util.*;
import com.googlecode.lanterna.screen.*;
public class Tile{
private int x, y; //x and y coordinates
private boolean isRoad, isStart, isEnd, hasTower, hasBalloon; //checks the status of the tile
private List<Balloon> onTile = new ArrayList<Balloon>(); //list of balloons on the tile
/**A tile constructor
*@param integers xCord and yCord are the x and y coordinates of the tile on the screen
*/
public Tile(int xCord, int yCord){
x = xCord;
y = yCord;
}
/**A method to get the x-coordinate of a tile
*@return int x
*/
public int getX(){
return x;
}
/**A method to get the y-coordinate of a tile
*@return int x
*/
public int getY(){
return y;
}
/**A method that returns whether the tile is a road tile (true) or a grass tile (false)
*@return boolean
*/
public boolean getIsRoad(){
return isRoad;
}
/**A method that returns whether a tile is the starting tile of the road (true)
*@return boolean
*/
public boolean getIsStart(){
return isStart;
}
/**A method that returns whether a tile is the ending tile of the road (true)
*@return boolean
*/
public boolean getIsEnd(){
return isEnd;
}
/**A method that returns whether a tile has a tower on it or not
*@return boolean
*/
public boolean getHasTower(){
return hasTower;
}
/**A method that returns whether a tile has a balloon on it or not
*@return boolean
*/
public boolean getHasBalloon(){
return hasBalloon;
}
/**A method that sets a tile as a road tile
*/
public void makeRoad(){
isRoad = true;
}
/**A method that sets a tile as a grass tile
*/
public void makeGrass(){
isRoad = false;
}
/**A method that makes a road tile the starting tile where balloons will spawn
*the tile must be a road tile in order to be the starting tile
the tile must not be the ending road tile
*@return boolean depending on if setting the tile as the start was successful
*/
public boolean makeStart(){
if(isRoad && !isEnd){
isStart = true;
return true;
}else{
return false;
}
}
/**A method that makes a road tile the ending tile where balloons will exit
*the tile must be a road tile in order to be the ending tile
the tile must not be the starting road tile
*@return boolean depending on if setting the tile as the end was successful
*/
public boolean makeEnd(){
if(isRoad && !isStart){
isEnd = true;
return true;
}else{
return false;
}
}
/**A method to get the list of balloons on the tile
*@return List<Balloon> onTile
*/
public List<Balloon> getBalloons(){
return onTile;
}
/**A method that draws the tile onto the terminal
**this is only used when a terminal is used for displaying the game; if a screen is used, this method is not needed
*@param Terminal t
*/
public void draw(Terminal t){
t.moveCursor(x, y);
t.applyBackgroundColor(Terminal.Color.WHITE);
t.putCharacter(' ');
t.applyBackgroundColor(Terminal.Color.DEFAULT);
t.applyForegroundColor(Terminal.Color.DEFAULT);
}
/**A method that draws the tile onto the screen
*@param Screen s
*/
public void draw(Screen s){
s.putString(x,y," ",Terminal.Color.DEFAULT,Terminal.Color.WHITE);
}
}