-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
153 lines (139 loc) · 4.71 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
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>WebGL Demo</title>
<link rel="stylesheet" href="../webgl.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/css/materialize.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.99.0/js/materialize.min.js"></script>
<style type="text/css">
html{
overflow-y: hidden;
overflow-x: hidden;
}
body{
background-color: black;
}
h1{
color: white;
font-family:sans-serif;
}
.container{
width: 100%
}
.card-content{
color:white;
}
#main_div{
width: 100%;
float: left;
max-width: 100%
}
</style>
<script>
//
// Initialize a texture and load an image.
// When the image finished loading copy it into the texture.
//
function loadTexture(gl, url) {
const texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
// Because images have to be download over the internet
// they might take a moment until they are ready.
// Until then put a single pixel in the texture so we can
// use it immediately. When the image has finished downloading
// we'll update the texture with the contents of the image.
const level = 0;
const internalFormat = gl.RGBA;
const width = 1;
const height = 1;
const border = 0;
const srcFormat = gl.RGBA;
const srcType = gl.UNSIGNED_BYTE;
const pixel = new Uint8Array([0, 0, 255, 255]); // opaque blue
gl.texImage2D(gl.TEXTURE_2D, level, internalFormat,
width, height, border, srcFormat, srcType,
pixel);
const image = new Image();
image.onload = function() {
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.texImage2D(gl.TEXTURE_2D, level, internalFormat,
srcFormat, srcType, image);
// WebGL1 has different requirements for power of 2 images
// vs non power of 2 images so check if the image is a
// power of 2 in both dimensions.
if (isPowerOf2(image.width) && isPowerOf2(image.height)) {
// Yes, it's a power of 2. Generate mips.
gl.generateMipmap(gl.TEXTURE_2D);
} else {
// No, it's not a power of 2. Turn off mips and set
// wrapping to clamp to edge
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
}
};
image.src = url;
return texture;
}
function isPowerOf2(value) {
return (value & (value - 1)) == 0;
}
</script>
</head>
<body>
<div id="main_div" class="container">
<div class="row">
<div class="white-text black col s3 card">
<br>
<br>
<br>
<br>
<h4 align="center" id="score_value">Score:</h4>
<br>
<br>
<br>
<h4 align="center"><u>Controls</u></h4>
<ul style="font-size:30px">
<li>
<pre> Left: Left Arrow key</pre>
</li>
<li>
<pre> Right: Right Arrow</pre>
</li>
<li>
<pre> Jump: Up Arrow key</pre>
</li>
<li>
<pre> Duck: Down Arrow key</pre>
</li>
<li>
<pre> Grayscale : g </pre>
</li>
</ul>
</div>
<div class="col s6 ">
<canvas id="glcanvas" width="1200" height="800"></canvas>
</div>
</div>
</div>
</body>
<script src="./gl-matrix.js"></script>
<script src="./cube.js"></script>
<script src="./track.js"></script>
<script src="./wall.js"></script>
<script src="./train.js"></script>
<script src="./coin.js"></script>
<script src="./obstacle.js"></script>
<script src="./player.js"></script>
<script src="./police.js"></script>
<script src="./dog.js"></script>
<script src="./boot.js"></script>
<script src="./jetpack.js"></script>
<script src="./finish.js"></script>
<script src="./mousetrap.js"></script>
<script src="./main.js"></script>
</html>