-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelStorer.java
More file actions
192 lines (169 loc) · 9.34 KB
/
LevelStorer.java
File metadata and controls
192 lines (169 loc) · 9.34 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
package andrieste;
import javafx.scene.layout.Pane;
import java.util.ArrayList;
/**
* This is the level storer class. It just is where the hardcoded levels are stored.
* There is no fancy algorithm or anything. I just went and created 5 custom levels
* and stored them in this class.
* I do know that there's a bunch of magic numbers in this class, but all of these numbers
* are just randomly chosen by me with just trial and error. I would need to make
* a lot of constants, and I was too lazy to do that, so I decided not to. Hopefully that's okay.
*/
public class LevelStorer {
private double[] respawnCoords;
/**
* Constructor. Just initialized respawn coords.
*/
public LevelStorer() {
this.respawnCoords = new double[2];
}
/**
* returns the array of respawn coordinates.
*/
public double[] getRespawnCoords() {
return respawnCoords;
}
/**
* Creates the arrayList of the collidable rectangles of level one and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelOne(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
collidables.add(new Platform(gamePane,0,Constants.SCENE_HEIGHT/2,100,20,false));
collidables.add(new ResetDashOrb(gamePane, 275, 360 - 250));
collidables.add(new SpikedPlatform(gamePane,287.5 -100,160, 200, 74, game, 1));
collidables.add(new Platform(gamePane,287.5-25,180 +54,50,300-54,true));
collidables.add(new Platform(gamePane,287.5+100,460,100,20,false));
collidables.add(new Platform(gamePane,625,20,25,410,true));
collidables.add(new Platform(gamePane,800,130,25,350,true));
collidables.add(new SlidingPlatform(gamePane, 875, 500, 100, 20, SlidingDirection.RIGHT));
collidables.add(new WinningPlatform(
gamePane, Constants.SCENE_WIDTH - 100, 300,100,20,game, Difficulty.EASY));
collidables.add(new SpikedPlatform(gamePane,Constants.SCENE_WIDTH - 100,320, 74, 200, game,
2));
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT/2 - 100;
return collidables;
}
/**
* Creates the arrayList of the collidable rectangles of level three and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelThree(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT - 200;
collidables.add(new Platform(gamePane,0,this.respawnCoords[1] +100,100,20,false));
collidables.add(new Platform(gamePane,250,200,37,400,true));
collidables.add(new BouncyPlatform(gamePane,0,300,100,20));
collidables.add(new SpikedPlatform(gamePane,250,0,37, 100, game, 2));
collidables.add(new SpikedPlatform(gamePane,287,300,200 -37, 60, game, 1));
collidables.add(new WinningPlatform(
gamePane, Constants.SCENE_WIDTH - 100, 250,100,20,game, Difficulty.EASY));
collidables.add(new ResetDashOrb(gamePane, 550, 150));
collidables.add(new SlidingPlatform(gamePane, 275, 620, 100, 20, SlidingDirection.RIGHT));
collidables.add(new Platform(gamePane,1000,670,100,20, false));
//collidables.add(new SpikedPlatform(gamePane,900,450,200, 20, game));
collidables.add(new ResetDashOrb(gamePane, 900-Constants.DASH_ORB_WIDTH/2, 325));
collidables.add(new ResetDashOrb(gamePane, 900-Constants.DASH_ORB_WIDTH/2, 100));
collidables.add(new Platform(gamePane,700,0,20,450, true));
return collidables;
}
/**
* Creates the arrayList of the collidable rectangles of level five and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelFive(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT - 150;
collidables.add(new Platform(gamePane,0,this.respawnCoords[1] +100,100,20,false));
collidables.add(new SlidingPlatform(gamePane, 200, 670, 50, 20, SlidingDirection.RIGHT));
collidables.add(new SlidingPlatform(gamePane, 700, 470, 50, 20, SlidingDirection.LEFT));
collidables.add(new SpikedPlatform(gamePane,850 -84,200,104, Constants.SCENE_HEIGHT-200, game,
3));
collidables.add(new Platform(gamePane,80,250,20,100,true));
collidables.add(new ResetDashOrb(gamePane, 250, 150));
collidables.add(new SlidingPlatform(gamePane, 400, 125, 50, 20, SlidingDirection.RIGHT));
collidables.add(new SpikedPlatform(gamePane,870,200,200, 20, game,4));
collidables.add(new ResetDashOrb(gamePane, 1150, 125));
collidables.add(new SpikedPlatform(gamePane,1070,350,Constants.SCENE_WIDTH-1070, 20, game,
4));
collidables.add(new ResetDashOrb(gamePane, 930, 400));
collidables.add(new ResetDashOrb(gamePane, 1150, 550));
collidables.add(new SpikedPlatform(gamePane,870,500,200, 20, game, 4));
collidables.add(new WinningPlatform(
gamePane, 870, Constants.SCENE_HEIGHT-20,100,20,game,
Difficulty.EASY));
return collidables;
}
/**
* Creates the arrayList of the collidable rectangles of level four and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelFour(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT - 200;
collidables.add(new Platform(gamePane,0,this.respawnCoords[1] +100,100,20,false));
collidables.add(new SlidingPlatform(gamePane, 200, 620, 50, 20, SlidingDirection.RIGHT));
collidables.add(new ResetDashOrb(gamePane, 930, 620));
collidables.add(new Platform(gamePane, Constants.SCENE_WIDTH-150, 620, 50, 20, false));
collidables.add(new Platform(gamePane, Constants.SCENE_WIDTH-20, 200, 20, 200, true));
collidables.add(new SlidingPlatform(gamePane, 950, 350, 50, 20, SlidingDirection.LEFT));
collidables.add(new ResetDashOrb(gamePane, 650, 400));
collidables.add(new SlidingPlatform(gamePane, 1050, 150, 50, 20, SlidingDirection.LEFT));
collidables.add(new ResetDashOrb(gamePane, 300, 150));
collidables.add(new SpikedPlatform(gamePane,300,200,100, 37, game, 1));
collidables.add(new SpikedPlatform(gamePane,600,200,100, 37, game, 1));
collidables.add(new WinningPlatform(
gamePane, 0, 200,100,20,game,
Difficulty.EASY));
return collidables;
}
/**
* Creates the arrayList of the collidable rectangles of level two and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelTwo(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT - 200;
collidables.add(new Platform(gamePane,0,this.respawnCoords[1] +100,100,20,false));
collidables.add(new ResetDashOrb(gamePane, 50, 275));
collidables.add(new Platform(gamePane,200,150,100,20,false));
collidables.add(new Platform(gamePane,0,150,20,100,true));
collidables.add(new Platform(gamePane,550,-100,20,100,true));
collidables.add(new SpikedPlatform(gamePane,510,0,60, 300, game, 3));
collidables.add(new SpikedPlatform(gamePane,360,200,60, 300, game, 3));
collidables.add(new Platform(gamePane,675,500,75,150, true));
collidables.add(new BouncyPlatform(gamePane,Constants.SCENE_WIDTH-100,500,100,20));
collidables.add(new Platform(gamePane,Constants.SCENE_WIDTH-20,0,20,300,true));
collidables.add(new ResetDashOrb(gamePane, 800, 75));
collidables.add(new SpikedPlatform(gamePane,950 +46,250,54, 20, game, 1));
collidables.add(new WinningPlatform(
gamePane, 570, 100,100,20,game,
Difficulty.EASY));
return collidables;
}
/**
* Creates the arrayList of the collidable rectangles of level six and returns them.
* Also sets changes respawn coordinates.
*/
public ArrayList<CollidableRectangle> getLevelSix(Pane gamePane, Game game) {
ArrayList<CollidableRectangle> collidables = new ArrayList<>();
this.respawnCoords[0] = 0;
this.respawnCoords[1] = Constants.SCENE_HEIGHT - 200;
collidables.add(new Platform(gamePane,0,this.respawnCoords[1] +100,200,20,false));
collidables.add(new Platform(gamePane,325,550,175,20,false));
collidables.add(new Platform(gamePane,480,200,20,350,true));
collidables.add(new Platform(gamePane,325,0,20,400,true));
collidables.add(new Platform(gamePane,525,550,100,20,false));
collidables.add(new Platform(gamePane,900,550,100,20,false));
collidables.add(new ResetDashOrb(gamePane,1000, 250));
collidables.add(new WinningPlatform(
gamePane, Constants.SCENE_WIDTH - 100, 200,100,20,game,
Difficulty.EASY));
return collidables;
}
}