-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWall.java
More file actions
86 lines (68 loc) · 2.03 KB
/
Wall.java
File metadata and controls
86 lines (68 loc) · 2.03 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
package org.example;
import com.googlecode.lanterna.terminal.Terminal;
import java.io.IOException;
public class Wall {
private int x;
private int y;
private char symbol;
private int previousX;
private int previousY;
Terminal terminal;
int length;
public Wall(int x, int y, int length, char symbol, Terminal terminal) throws IOException {
this.x = x;
this.y = y;
this.length = length;
this.symbol = symbol;
this.terminal = terminal;
for (int i = 0; i < length; i++) {
terminal.setCursorPosition(getX(), getY());
terminal.putCharacter(getSymbol());
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public char getSymbol() {
return symbol;
}
public void setSymbol(char symbol) {
this.symbol = symbol;
}
public int getPreviousX() {
return previousX;
}
public int getPreviousY() {
return previousY;
}
public boolean moveWall() throws IOException {
previousX = x;
previousY = y;
for (int i = 0; i < length; i++) {
terminal.setCursorPosition(previousX, previousY + i);
terminal.putCharacter(' ');
}
this.x -= 2;
for (int i = 0; i < length; i++) {
if (Main.player.getY() == y + i && Main.player.getX() == x + i) {
WallManager.continueReadingInput = false;
String message = "GAME OVER!";
terminal.flush();
for (int b = 0; b < message.length(); b++) {
terminal.setCursorPosition(30 + b, 10);
terminal.putCharacter(message.charAt(b));
terminal.flush();
}
}
if (x < 2) {
return false;
}
terminal.setCursorPosition(x, y + i);
terminal.putCharacter(getSymbol());
}
return true;
}
}