-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
104 lines (85 loc) · 4.45 KB
/
index.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
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Le donjon</title>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="https://code.createjs.com/preloadjs-0.6.2.min.js"></script>
<script>
var offsetXMainWall = 400;
var offsetYMainWall = 0;
var wallSize = 250;
var verticalDeformationOffset = 245;
var verticalDeformationXOffset = 140;
function handleFileComplete(event) {
document.getElementById("loading").style.display = "none";
var c = document.getElementById("world");
var ctx = c.getContext("2d");
if(event.item.id === 'assets/wall.jpg'){
ctx.drawImage(event.result, offsetXMainWall,0+offsetYMainWall, wallSize, wallSize);
ctx.drawImage(event.result, wallSize+offsetXMainWall,0+offsetYMainWall, wallSize, wallSize);
ctx.drawImage(event.result, 2*wallSize+offsetXMainWall,0+offsetYMainWall, wallSize, wallSize);
ctx.drawImage(event.result, 3*wallSize+offsetXMainWall,0+offsetYMainWall, wallSize, wallSize);
ctx.drawImage(event.result, 4*wallSize+offsetXMainWall,0+offsetYMainWall, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
ctx.drawImage(event.result, wallSize+offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
ctx.drawImage(event.result, 3*wallSize+offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
/* Left wall*/
ctx.transform(1,0,0,1,verticalDeformationXOffset,verticalDeformationOffset);
ctx.transform(1,-1.9,0,1,0,0);
ctx.transform(0.4,0,0,1,0,0);
ctx.drawImage(event.result, offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall-wallSize,0+offsetYMainWall+wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall,0+offsetYMainWall+2*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall-wallSize,0+offsetYMainWall+2*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall-2*wallSize,0+offsetYMainWall+wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall-2*wallSize,0+offsetYMainWall+2*wallSize, wallSize, wallSize);
ctx.transform(2.5,0,0,1,0,0);
ctx.transform(1,1.9,0,1,0,0);
ctx.transform(1,0,0,1,-verticalDeformationXOffset,-verticalDeformationOffset);
}
if(event.item.id === 'assets/door.jpg'){
ctx.drawImage(event.result, 2*wallSize+offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
}
if(event.item.id === 'assets/window.jpg'){
ctx.drawImage(event.result, 4*wallSize+offsetXMainWall,0+offsetYMainWall+wallSize, wallSize, wallSize);
}
if(event.item.id === 'assets/floor.png'){
ctx.transform(1,0,0,1,wallSize-50,120);
ctx.transform(1,0,-0.525,1,0,0);
ctx.transform(1,0,0,0.75,0,0);
ctx.drawImage(event.result, offsetXMainWall, offsetYMainWall+2*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, wallSize+offsetXMainWall, offsetYMainWall+2*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall, offsetYMainWall+3*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, wallSize+offsetXMainWall, offsetYMainWall+3*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, offsetXMainWall, offsetYMainWall+4*wallSize, wallSize, wallSize);
ctx.drawImage(event.result, wallSize+offsetXMainWall, offsetYMainWall+4*wallSize, wallSize, wallSize);
ctx.transform(1,0,0,1/0.75,0,0);
ctx.transform(1,0,0.525,1,0,0);
ctx.transform(1,0,0,1,-wallSize+50,-120);
}
}
document.addEventListener("DOMContentLoaded", function(event) {
var preload = new createjs.LoadQueue();
preload.addEventListener("fileload", handleFileComplete);
preload.loadFile("config.json");
preload.loadFile("levels/level1.json");
preload.loadFile("assets/wall.jpg"); /*http://textures.christopherjonhewitt.com/medieval-2/*/
preload.loadFile("assets/floor.png");
preload.loadFile("assets/door.jpg");
preload.loadFile("assets/window.jpg");
preload.loadFile("assets/avatar.png");
preload.loadFile("assets/sounds/ambiance.mp3");
preload.loadFile("assets/sounds/door.mp3");
});
</script>
</head>
<body style="margin:0;padding:0;overflow:hidden;">
<div id="loading">Chargement en cours ... </div>
<canvas id="world" width="1920" height="1080" style="border:0px;">
Ce navigateur ne supporte pas HTML5 canvas
</canvas>
</body>
</html>