-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data.java
135 lines (122 loc) · 4.73 KB
/
Data.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
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
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import java.util.ArrayList;
import java.util.Random;
public class Data {
public Powerup powerup;
public BasicBlock[][] map;
public ArrayList<Enemy> enem;
public Player player;
public Eagle eagle;
private static Data aData;
public int timefreeze = 0;
public int timefreeze(int f) {
timefreeze = timefreeze+f;
return timefreeze;
}
public void makePowerup() {
if (!powerup.on) {
Random rand = new Random();
int dv = rand.nextInt(3) + 1;
Random rand1 = new Random();
int rt = rand1.nextInt(4) + 1;
Location fr;
if (rt == 1) {
fr = new Location(12*40, 12*40);
} else if (rt == 2) {
fr = new Location(5*40, 12*40);
} else if (rt == 3){
fr = new Location(5*40, 0);
} else {
fr = new Location (240, 240);
}
powerup.newPowerup(fr, dv);
powerup.avail = true;
}
}
private Data() {
powerup = new Powerup(new Location(-40, -40), 1);
map = new BasicBlock[13][13];
int rowVal = 0;
for (int row = 0; row < 13; row++) { // Defining the array map EMPTY.
int colVal = 0;
for (int col = 0; col < 13; col++) {map[row][col] = new SpaceBlock(new Location(-40, -40), new Image("player_left.png"));
colVal = colVal + 40;
}
rowVal = rowVal + 40;
}
/*
HARDCODING THE WALLS.
*/
for (int row = 1; row < 5; row ++){
for (int col = 1; col < 5; col = col + 2) {
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
}
for (int row = 1; row < 5; row ++){
for (int col = 9; col < 13; col = col + 2) {
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
}
for (int row = 9; row < 12; row ++){
for (int col = 1; col < 5; col = col + 2) {
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
}
for (int row = 9; row < 12; row ++){
for (int col = 9; col < 13; col = col + 2) {
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
}
for (int row = 1; row < 4; row ++){
for (int col = 5; col < 9; col = col + 2) {
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
}
for (int col = 2; col < 11; col++) {
int row = 6;
if (col < 4 || col > 8)
map[row][col] = new BrickBlock(new Location(row*40, col*40), new Image("bricks.png"));
}
map[5][5] = new BrickBlock(new Location(5*40, 5*40), new Image("bricks.png"));
map[5][7] = new BrickBlock(new Location(5*40, 7*40), new Image("bricks.png"));
map[11][6] = new BrickBlock(new Location(11*40, 6*40), new Image("bricks.png"));
map[11][5] = new BrickBlock(new Location(11*40, 5*40), new Image("bricks.png"));
map[11][7] = new BrickBlock(new Location(11*40, 7*40), new Image("bricks.png"));
map[9][7] = new BrickBlock(new Location(9*40, 7*40), new Image("bricks.png"));
map[9][5] = new BrickBlock(new Location(9*40, 5*40), new Image("bricks.png"));
map[8][7] = new BrickBlock(new Location(8*40, 7*40), new Image("bricks.png"));
map[8][5] = new BrickBlock(new Location(8*40, 5*40), new Image("bricks.png"));
map[12][5] = new BrickBlock(new Location(12*40, 5*40), new Image("bricks.png"));
map[12][7] = new BrickBlock(new Location(12*40, 7*40), new Image("bricks.png"));
eagle = new Eagle(new Location(12*40, 6*40));
map[12][6] = eagle;
map[3][6] = new SteelBlock(new Location(3*40, 6*40));
map[6][12] = new SteelBlock(new Location(6*40, 12*40));
map[6][0] = new SteelBlock(new Location(6*40, 0*40));
/*
-------------------- END.
*/
for (int row = 0; row < 13; row++) { // PRINT MAP.
for (int col = 0; col < 13; col++) {
map[row][col].iv = new ImageView(map[row][col].image);
map[row][col].iv.setX(map[row][col].location.getCol());
map[row][col].iv.setY(map[row][col].location.getRow());
map[row][col].iv.setFitHeight(40);
map[row][col].iv.setFitWidth(40);
}
}
Location loc = new Location(0,0);
player = new Player(loc);
enem = new ArrayList<Enemy>();
Location loce = new Location(0,80);
Enemy xy = new Enemy(loce);
enem.add(xy);
}
public static Data getData() {
if (aData == null) {
aData = new Data();
}
return aData;
}
}