-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelRaw.java
More file actions
33 lines (28 loc) · 1.04 KB
/
Copy pathLevelRaw.java
File metadata and controls
33 lines (28 loc) · 1.04 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
// For some odd reason if I don't seperate this out into it's own JAVA
// file then it errors out saying that main (the project name) cannot
// be serialized even though it is never referred to
// NOTE: I realise I could have just made a 3D array and had many different layers instead of just the object and tile layers.
// However, I've already serialized a few levels and making a converter for such a small change seems redundant for this
// game. An example of what I mean int[][][] grid (meaning an array (layer) of arrays (columns) of an array (rows))
// Level types
enum LevelType {
DESERT,
GRASS,
DUNGEON
}
// Serializable object, the stuff that actually matters to store it
class LevelRaw implements java.io.Serializable {
LevelType type;
int[][] tileGrid;
int[][] objectGrid;
LevelRaw() {
type = LevelType.DESERT;
tileGrid = new int[0][0];
objectGrid = new int[0][0];
}
LevelRaw(LevelType type_, int[][] tileGrid_, int[][] objectGrid_) {
type = type_;
tileGrid = tileGrid_;
objectGrid = objectGrid_;
}
}