-
Notifications
You must be signed in to change notification settings - Fork 20
/
mapcreator.html
184 lines (169 loc) · 6.18 KB
/
mapcreator.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
184
<html>
<head>
<title>Pwn Adventure Z Map Editor</title>
<script langauge='javascript'>
data = []
for (var i = 0; i < 32 * 22; i++)
data[i] = 0xc1;
function update_data() {
result = "\t.byte ";
for (var i = 0; i < 32 * 22; i++) {
if ((i > 0) && ((i % 16) == 0))
result += "\n\t.byte ";
else if (i > 0)
result += ", ";
value = data[i].toString(16);
if (value.length < 2)
value = "0" + value;
result += "$" + value;
}
document.getElementById('data').value = result;
}
function load_map() {
text = document.getElementById('data').value;
for (var i = 0; i < 32 * 22; i++) {
text = text.substr(text.indexOf("$") + 1);
data[i] = parseInt(text.substr(0, 2), 16);
if ((i % 32) < 26)
data_img[i].src = images[data[i]];
text = text.substr(2);
}
update_data();
}
function map_clicked(x, y) {
data[(y * 32) + x] = active;
data_img[(y * 32) + x].src = images[active];
update_data();
}
function create_single_tile(parent, title, name, value) {
var col = document.createElement('td');
col.style.verticalAlign = 'top';
col.innerHTML = "<small>" + title + "</small><br/><img src='images/" + name + ".png' onclick='active=" +
value.toString() + "'>";
parent.appendChild(col);
images[value] = 'images/' + name + '.png';
}
function create_tile_set(parent, title, name, value) {
var col = document.createElement('td');
col.style.verticalAlign = 'top';
col.innerHTML = "<small>" + title + "</small><br/>" +
"<img src='images/" + name + "_00.png' onclick='active=" + value.toString() + "'>" +
"<img src='images/" + name + "_40.png' onclick='active=" + (value + 0x40).toString() + "'><br/>" +
"<img src='images/" + name + "_80.png' onclick='active=" + (value + 0x80).toString() + "'>" +
"<img src='images/" + name + "_c0.png' onclick='active=" + (value + 0xc0).toString() + "'>";
parent.appendChild(col);
images[value] = 'images/' + name + '_00.png';
images[value + 0x40] = 'images/' + name + '_40.png';
images[value + 0x80] = 'images/' + name + '_80.png';
images[value + 0xc0] = 'images/' + name + '_c0.png';
}
function init() {
map = document.getElementById('map');
update_data();
var table = document.createElement('table');
data_img = [];
for (var y = 0; y < 22; y++) {
var row = document.createElement('tr');
for (var x = 0; x < 26; x++) {
var col = document.createElement('td');
var img = document.createElement('img');
img.src = 'images/boundary.png';
img.onmouseenter = function() { this.style.opacity = 0.5; };
img.onmouseleave = function() { this.style.opacity = 1; };
img.onclick = function() { map_clicked(this.map_x, this.map_y); };
img.map_x = x;
img.map_y = y;
img.style.opacity = 1;
data_img[(y * 32) + x] = img;
col.appendChild(img);
col.style.border = 0;
col.style.padding = 0;
row.appendChild(col);
}
row.style.border.width = 0;
row.style.padding = 0;
table.appendChild(row);
}
table.style.borderSpacing = 0;
map.appendChild(table);
tiles = document.getElementById('tiles');
var table = document.createElement('table');
tiles.appendChild(table);
var row = document.createElement('tr');
table.appendChild(row);
images = [];
create_single_tile(row, "Boundary", "boundary", 0xc1);
create_single_tile(row, "Lake", "lake", 0xc7);
create_tile_set(row, "Start", "start", 0x00);
create_tile_set(row, "Starting cave", "startcave", 0x0e);
create_tile_set(row, "Cave", "cave", 0x02);
create_tile_set(row, "Cave chest", "cavechest", 0x18);
create_tile_set(row, "Cave boss", "caveboss", 0x19);
var row = document.createElement('tr');
table.appendChild(row);
create_tile_set(row, "House", "house", 0x04);
create_tile_set(row, "Boarded house", "boardedhouse", 0x17);
create_tile_set(row, "Shop", "shop", 0x05);
create_tile_set(row, "Secret Shop", "secretshop", 0x27);
create_tile_set(row, "Outpost Shop", "outpostshop", 0x28);
create_tile_set(row, "Outpost House", "outposthouse", 0x2a);
create_tile_set(row, "Park", "park", 0x06);
var row = document.createElement('tr');
table.appendChild(row);
create_tile_set(row, "Boss", "boss", 0x08);
create_tile_set(row, "Base horde", "basehorde", 0x09);
create_tile_set(row, "Base", "base", 0x0a);
create_tile_set(row, "Blocky treasure", "blockytreasure", 0xb);
create_tile_set(row, "Blocky puzzle", "blockypuzzle", 0xc);
create_tile_set(row, "Blocky cave", "blockycave", 0xd);
create_tile_set(row, "Mine up", "minedown", 0x2c);
create_tile_set(row, "Mine", "cave", 0x2d);
var row = document.createElement('tr');
table.appendChild(row);
create_tile_set(row, "Lost Cave", "lostcave", 0x0f);
create_tile_set(row, "Lost Wall", "lostcavewall", 0x24);
create_tile_set(row, "Lost Chest", "lostcavechest", 0x25);
create_tile_set(row, "Lost End", "lostcaveend", 0x26);
create_tile_set(row, "Mine entrance", "mineenter", 0x10);
create_tile_set(row, "Mine down", "minedown", 0x11);
create_tile_set(row, "Mine chest", "minechest", 0x1b);
create_tile_set(row, "Mine boss", "mineboss", 0x1c);
var row = document.createElement('tr');
table.appendChild(row);
create_tile_set(row, "Dead Wood", "deadwood", 0x12);
create_tile_set(row, "Dead Chest", "deadwoodchest", 0x20);
create_tile_set(row, "Dead Boss", "deadwoodboss", 0x21);
create_tile_set(row, "Sewer", "sewer", 0x1d);
create_tile_set(row, "Sewer Chest", "sewerchest", 0x1e);
create_tile_set(row, "Sewer Boss", "sewerboss", 0x1f);
create_tile_set(row, "Sewer Down", "sewerdown", 0x29);
create_tile_set(row, "Sewer Up", "sewerdown", 0x2b);
var row = document.createElement('tr');
table.appendChild(row);
create_tile_set(row, "Starting forest", "startforest", 0x14);
create_tile_set(row, "Start chest", "startforestchest", 0x15);
create_tile_set(row, "Start boss", "startforestboss", 0x16);
create_tile_set(row, "Forest", "forest", 0x03);
create_tile_set(row, "Forest Chest", "forestchest", 0x1a);
create_tile_set(row, "Unbearable", "bear", 0x13);
create_tile_set(row, "bear Chest", "bearchest", 0x22);
create_tile_set(row, "bear Boss", "bearboss", 0x23);
}
active = 0xc1;
</script>
</head>
<body onload="init()">
<table>
<tr>
<td><div id="map"></div></td>
<td valign='top'><div id="tiles">
</div></td>
</tr>
</table>
<pre>
Raw map data:
<textarea id="data" cols="120" rows="49"></textarea>
<button type="button" onclick="load_map()">Load</button>
</pre>
</body>
</html>