-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
141 lines (116 loc) · 3.6 KB
/
game.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
<!doctype html>
<html lang="en">
<head>
<title>Space Encounters</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<style type="text/css">
body {
padding:0;
margin:0;
font-weight: bold;
overflow:hidden;
background-image: url(textures/background/Grand_Universe.jpg);
background-size: 100%;
}
#hud
{
position: absolute;
left: 5px;
top: 5px;
color: white;
font-family: sans-serif;
font-size: 8pt;
z-index: 100;
}
#hud .value
{
color: yellow;
}
#space
{
background: black;
border: 5px solid #5899ff;
margin: auto;
position: absolute;
left: 200px;
top: 10px;
}
#menu h1
{
color: white;
}
#menu a
{
color: white;
text-decoration: none;
}
</style>
</head>
<body onresize="resize()">
<div id="menu" style="float: left; width: 200px; text-align: center;">
<h1>Space Encounters</h1>
<p><a href="game.html?0">Level 0</a></p>
<p><a href="game.html?1">Level 1</a></p>
<p><a href="game.html?2">Level 2</a></p>
<p><a href="game.html?3">Level 3</a></p>
<p><a href="game.html?8">Multiplayer</a></p>
</div>
<div id="space" style="width: 70%; height: 90%;"></div>
<script type="text/javascript" src="lib/require/require.js"></script>
<script type="text/javascript">
require.config({
baseUrl: "game",
paths: {
"three": "../lib/three"
},
waitSeconds: 15
});
var index = levelName = window.location.href.indexOf('?');
var levelName = index > 0 ? window.location.href.substring(index + 1) : '1';
var level, container;
require(['levels/Level' + levelName, 'three/Stats'], function (Level) {
init(Level);
animate();
});
function init(Level) {
var ww = window.innerWidth - 220;
var wh = window.innerHeight - 30;
var ratio = 4 / 3;
var h = Math.floor(Math.min(wh, ww / ratio));
var w = Math.floor(ratio * h);
container = document.getElementById('space');
container.setAttribute("style", 'width: ' + w + 'px; height: ' + h + 'px;');
document.body.appendChild(container);
level = new Level({
container: container
});
level.initialize();
// stats
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
stats.domElement.style.right= '0px';
stats.domElement.style.zIndex = 100;
container.appendChild(stats.domElement);
}
function resize() {
var ww = window.innerWidth - 220;
var wh = window.innerHeight - 30;
var ratio = 4 / 3;
var h = Math.floor(Math.min(wh, ww / ratio));
var w = Math.floor(ratio * h);
if (container)
container.setAttribute("style", 'width: ' + w + 'px; height: ' + h + 'px;');
if (level)
level.resize(w);
}
function animate() {
requestAnimationFrame(animate);
level.advance();
level.render();
stats.update();
}
</script>
</body>
</html>