forked from paranerd/MMORPG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Level.js
executable file
·114 lines (99 loc) · 4.09 KB
/
Level.js
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
/* =====
Level
===== */
var Level = function() {
// size in the world in sprite tiles
world = [[]];
npcList = [[]];
worldSize = 37;
// size of a tile in pixels
tileSize = 32;
map = [[2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2],
[2,2,2,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,2,2],
[2,2,3,3,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,2],
[2,3,3,0,0,0,0,0,0,1,0,0,0,1,3,3,3,3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],
[3,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],
[3,0,0,0,0,0,1,0,0,0,0,0,3,2,2,2,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],
[3,0,0,0,0,0,0,0,0,0,0,0,3,2,2,2,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],
[3,0,0,0,0,0,0,0,0,0,0,0,0,3,2,2,2,2,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3],
[3,0,0,0,0,0,0,0,0,0,0,0,0,0,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3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2],
[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]];
// Format: [name, xTile, yTile, type, hasQuest, questID]
npcs = [["Egon der Schankwirt", 7, 5, 0, 0, true, 0],
["Hugo der Ritter", 7, 8, 1, 0, false, null],
["Rupert der Kräutermixer", 8, 6, 0, 0, true, 2]
];
var changeTo = function(num)
{
// create emptiness
for (var x=0; x < worldSize; x++)
{
world[x] = [];
for (var y=0; y < worldSize; y++)
{
world[x][y] = 0;
}
}
for(var y=0; y<worldSize; y++) {
for(var x=0; x<worldSize; x++) {
world[x][y] = map[y][x];
}
}
};
var init = function()
{
// Link level
level = this;
// Init first level
level.changeTo(1);
};
var getMap = function() {
return world;
};
var getNpcList = function() {
return npcs;
};
var getWorldSize = function() {
return worldSize;
};
var getTileSize = function() {
return tileSize;
};
// Which variables and methods can be accessed
return {
init: init,
changeTo: changeTo,
getMap: getMap,
getNpcList: getNpcList,
getWorldSize: getWorldSize,
getTileSize: getTileSize,
}
};
exports.Level = Level;