-
Notifications
You must be signed in to change notification settings - Fork 0
/
tileMapTest.html
121 lines (117 loc) · 5.11 KB
/
tileMapTest.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<canvas id="canvi" width="640" height="128" style="background: black; border: 1px solid #00000055; width: 2560px;"></canvas>
<div style="background:#FFFFFF99;position:fixed;top:5px;left:5px;">
<input type="checkbox" id="eA">enable angles</input>
<input type="number" id="numBox" min="0" max="0"></input>
</div>
<script></script>
<script>
function newImage(src) {
var thisImage = document.createElement("img");
thisImage.src = src;
return thisImage;
}
</script>
<script src="engine/tileSystem.js"></script>
<script src="levels/tileset0.js"></script>
<script>
var canvi = document.getElementById("canvi");
canvi.style.imageRendering = "crisp-edges";
var c = canvi.getContext("2d");
c.imageSmoothingEnabled = false;
var eACheck = document.getElementById("eA");
var numBox = document.getElementById("numBox");
numBox.max = chunks.length-1;
var tileIndex = 10;
var enableAngles = true;
window.setInterval(draw, 17);
function draw() {
tileIndex = numBox.value;
enableAngles = eACheck.checked;
c.fillStyle = "black";
c.fillRect(0, 0, 640, 128);
c.drawImage(chunks[tileIndex].img, 0, 0);
c.save();
c.translate(128,0);
c.drawImage(chunks[tileIndex].img, 0, 0);
for(var x = 0; x < 8; x++){
for(var y = 0; y < 8; y++){
c.strokeStyle = "#FFFFFF55";
c.strokeRect(x*16,y*16,16,16);
c.strokeStyle = "";
for(var i = 0; i < 16; i++){
c.fillStyle = "#FF000099";
if(chunks[tileIndex].tiles[y][x][i] && chunks[tileIndex].tiles[y][x][i] != -16)
c.fillRect(x*16+i,y*16+16-chunks[tileIndex].tiles[y][x][i],1,chunks[tileIndex].tiles[y][x][i]);
}
c.fillStyle = "white";
if(chunks[tileIndex].tiles[y][x][16]&&enableAngles)
c.fillText(chunks[tileIndex].tiles[y][x][16],x*16,y*16+16)
}
}
c.translate(128,0);
c.drawImage(chunks[tileIndex].img, 0, 0);
c.fillStyle = "#FF000099";
for(var x = 0; x < 8; x++){
for(var y = 0; y < 8; y++){
c.strokeStyle = "#FFFFFF55";
c.strokeRect(x*16,y*16,16,16);
c.strokeStyle = "";
for(var i = 0; i < 16; i++){
c.fillStyle = "#FF000099";
if(chunks[tileIndex].btiles[y][x][i] && chunks[tileIndex].btiles[y][x][i] != -16)
c.fillRect(x*16+i,y*16,1,17-chunks[tileIndex].btiles[y][x][i]);
}
c.fillStyle = "white";
if(chunks[tileIndex].btiles[y][x][16]&&enableAngles)
c.fillText(chunks[tileIndex].btiles[y][x][16],x*16,y*16+16)
}
}
c.translate(128,0);
c.drawImage(chunks[tileIndex].img, 0, 0);
c.fillStyle = "#FF000099";
for(var x = 0; x < 8; x++){
for(var y = 0; y < 8; y++){
c.strokeStyle = "#FFFFFF55";
c.strokeRect(x*16,y*16,16,16);
c.strokeStyle = "";
for(var i = 0; i < 16; i++){
c.fillStyle = "#FF000099";
if(chunks[tileIndex].ltiles[x][y][i] && chunks[tileIndex].ltiles[x][y][i] != -16)
c.fillRect(x*16+16-chunks[tileIndex].ltiles[x][y][i],y*16+i,chunks[tileIndex].ltiles[x][y][i],1);
}
c.fillStyle = "white";
if(chunks[tileIndex].ltiles[x][y][16]&&enableAngles)
c.fillText(chunks[tileIndex].ltiles[x][y][16],x*16,y*16+16)
}
}
c.translate(128,0);
c.drawImage(chunks[tileIndex].img, 0, 0);
c.fillStyle = "#FF000099";
for(var x = 0; x < 8; x++){
for(var y = 0; y < 8; y++){
c.strokeStyle = "#FFFFFF55";
c.strokeRect(x*16,y*16,16,16);
c.strokeStyle = "";
for(var i = 0; i < 16; i++){
c.fillStyle = "#FF000099";
if(chunks[tileIndex].rtiles[x][y][i] && chunks[tileIndex].rtiles[x][y][i] != -16)
c.fillRect(x*16,y*16+i,17-chunks[tileIndex].rtiles[x][y][i],1);
}
c.fillStyle = "white";
if(chunks[tileIndex].rtiles[x][y][16]&&enableAngles)
c.fillText(chunks[tileIndex].rtiles[x][y][16],x*16,y*16+16)
}
}
c.restore();
}
</script>
</body>
</html>