-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWallManager.java
More file actions
42 lines (35 loc) · 1.11 KB
/
WallManager.java
File metadata and controls
42 lines (35 loc) · 1.11 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
package org.example;
import com.googlecode.lanterna.terminal.Terminal;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Random;
public class WallManager {
Terminal terminal;
Random r = new Random();
long doItTicks = 0;
LinkedList<Wall> listOfWalls = new LinkedList<>();
Player player;
static boolean continueReadingInput = true;
public boolean isContinueReadingInput() {
return continueReadingInput;
}
public WallManager(Terminal terminal) throws IOException {
this.terminal = terminal;
listOfWalls.add(new Wall(70, 10, 5, 'X', terminal));
}
public void doIt() throws IOException {
doItTicks++;
if (doItTicks % 4 == 0) {
listOfWalls.add(new Wall(70, r.nextInt(16) + 2, r.nextInt(10) + 2, 'X', terminal));
}
LinkedList<Wall> toBeRemoved = new LinkedList<>();
for (Wall wall : listOfWalls) {
if (!wall.moveWall()) {
toBeRemoved.add(wall);
}
}
for (Wall wall : toBeRemoved) {
listOfWalls.remove(wall);
}
}
}