-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdrive.html
44 lines (40 loc) · 984 Bytes
/
drive.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
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Drive.html</title>
<script type = "text/javascript"
src = "simpleGame.js"></script>
<script type = "text/javascript">
var scene;
var car;
function init(){
scene = new Scene();
car = new Sprite(scene, "car.gif", 50, 30);
car.setSpeed(3);
car.setAngle(0);
scene.start();
} // end init
function update(){
scene.clear();
if (keysDown[K_LEFT]){
car.changeAngleBy(-5);
}
if (keysDown[K_RIGHT]){
car.changeAngleBy(5);
}
if (keysDown[K_UP]){
car.changeSpeedBy(1);
}
if (keysDown[K_DOWN]){
car.changeSpeedBy(-1);
}
car.update();
} // end update
</script>
</head>
<body onload = "init()">
<title>Drive.html</title>
<h1>A basic car you can drive</h1>
</body>
</html>