-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex-isomer.html
183 lines (169 loc) · 5.59 KB
/
index-isomer.html
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
<!DOCTYPE html>
<html>
<head>
<title>Astonia Map Viewer</title>
<link href="css/bootstrap.min.css" rel="stylesheet" />
<style>
body,
html {
color: #ccc;
background: #262626;
font-family: monospace;
height: 100%;
width: 100%;
}
.floor {
transform: rotateX(55deg) rotateZ(45deg);
}
.tile {
display: inline-block;
background: #111;
width: 48px;
height: 48px;
box-shadow: 0 0 0 0.1em hsla(0, 0%, 0%, 0.2);
border: solid 1px gray;
position: relative;
}
.tile.color1 {
background: #004085;
}
.tile.color2 {
background: #383d41;
}
.tile.color3 {
background: #155724;
}
.tile.color4 {
background: #721c24;
}
.tile.color5 {
background: #856404;
}
.tile.color6 {
background: #0c5460;
}
</style>
</head>
<body>
<canvas
id="canvas"
style="width: 5000px; height: 5000px"
width="5000px"
height="5000px"
></canvas>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/isomer.min.js"></script>
<script>
var iso = new Isomer(document.getElementById("canvas"), {
//originX: 500, // Smaller moves left, larger moves right
//originY: 1500, // Smaller moves up, larger moves down
scale: 10,
});
var Shape = Isomer.Shape;
var Path = Isomer.Path;
var Point = Isomer.Point;
var Color = Isomer.Color;
let addPoint = (x, y, r, g, b) => {
iso.add(
new Path([
Point(x, y, 0),
Point(x + 1, y, 0),
Point(x + 1, y + 1, 0),
Point(x, y + 1, 0),
]),
new Color(r, g, b)
);
};
var fSpriteCodes = [];
var gSpriteCodes = [];
$.ajax({
url: "zones/2/below2.map",
dataType: "text",
success: (data, status) => {
// Split by blank line.
let blocks = data.split("\n\n");
for (let block of blocks) {
let lines = block.split("\n");
let blockData = {};
for (let line of lines) {
let pieces = line.split("=");
let key = pieces[0];
let value = pieces[1];
if (key == "field") {
let coords = value.split('"')[1].split(",");
blockData.x = parseInt(coords[0]);
blockData.y = parseInt(coords[1]);
} else if (key == "fsprite") {
// Thing
blockData.sprite = parseInt(value);
if (fSpriteCodes.indexOf(blockData.sprite) === -1) {
fSpriteCodes.push(blockData.sprite);
}
// Use the sprite index as the colour
blockData.red2 = fSpriteCodes.indexOf(blockData.sprite);
blockData.green2 = fSpriteCodes.indexOf(blockData.sprite);
blockData.blue2 = 255;
blockData.hasThing = true;
} else if (key == "gsprite") {
// Ground
blockData.sprite = parseInt(value);
if (gSpriteCodes.indexOf(blockData.sprite) === -1) {
gSpriteCodes.push(blockData.sprite);
}
// Use the sprite index as the colour
blockData.red = gSpriteCodes.indexOf(blockData.sprite);
blockData.green = 255;
blockData.blue = fSpriteCodes.indexOf(blockData.sprite);
}
}
addPoint(
blockData.x,
blockData.y,
blockData.hasThing ? blockData.red2 : blockData.red,
blockData.hasThing ? blockData.green2 : blockData.green,
blockData.hasThing ? blockData.blue2 : blockData.blue
);
}
// Now load enemies
$.ajax({
url: "zones/2/below2_generic.itm",
dataType: "text",
success: (data, status) => {
// Split by blank line.
let blocks = data.split("\n\n");
for (let block of blocks) {
let lines = block.split("\n");
let blockData = {};
for (let line of lines) {
let pieces = line.split("=");
let key = pieces[0];
let value = pieces[1];
if (key == "sprite") {
blockData.sprite = parseInt(value);
// Sprite is a number from 0 to 250071, so map this to colours.
blockData.red = 255;
blockData.green = blockData.sprite % 255;
blockData.blue = blockData.sprite % 255;
} else if (key == "arg") {
let code = value.split('"')[1];
// x[2], y[4], a[4], quiet[4]
blockData.x = parseInt(code.substring(0, 2), 16);
blockData.y = parseInt(code.substring(2, 6), 16);
}
}
addPoint(
blockData.x,
blockData.y,
blockData.red,
blockData.green,
blockData.blue
);
}
},
});
},
});
</script>
</body>
</html>