-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path06-transition-effects.html
60 lines (52 loc) · 1.94 KB
/
06-transition-effects.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Transition Effects</title>
<link href="../unicodetiles/unicodetiles.css" rel="stylesheet" type="text/css" />
<link href="../docs/style.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="../unicodetiles/unicodetiles.js"></script>
<script src="../unicodetiles/ut.WebGLRenderer.js"></script>
<script src="../unicodetiles/ut.CanvasRenderer.js"></script>
<script src="../unicodetiles/ut.DOMRenderer.js"></script>
<script src="../unicodetiles/input.js"></script>
<script src="renderer-switcher.js"></script>
<!-- We are extending the simple-dungeon example -->
<script src="simple-dungeon.js"></script>
<script>
// Alternative tile function
function getAnotherTile(x, y) {
var t = "";
try { t = map[map.length - y - 1][x]; }
catch(err) { return ut.NULLTILE; }
if (t === '#') return WALL;
if (t === '.') return FLOOR;
return ut.NULLTILE;
}
var flipflop = false;
function doTransition() {
var effects = [ "boxin", "boxout", "circlein", "circleout", "random" ];
var effect = effects[Math.floor(Math.random()*effects.length)];
var duration = Math.floor(Math.random() * 1500) + 500;
flipflop = !flipflop;
if (flipflop) eng.setTileFunc(getAnotherTile, effect, duration);
else eng.setTileFunc(getDungeonTile, effect, duration);
}
function initEffect() {
setInterval(doTransition, 2500);
pl.x = 14; pl.y = 10;
}
</script>
</head>
<body onload="initSimpleDungeon(); initEffect(); createRendererSwitcher();">
<p class="centerer">Observe random transition effects.</p>
<div class="centerer">
<div id="game">Enable JavaScript and reload the page.</div>
</div>
<div class="centerer" id="renderer-switcher">
<!-- Populated by renderer-switcher.js -->
</div>
<a class="backlink" href="index.html"><-- Back to index</a>
</body>
</html>