/
index.html
56 lines (50 loc) · 1.84 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
<html>
<head>
<title>Orbital</title>
<link href='http://fonts.googleapis.com/css?family=Amaranth:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/orbital.css">
</head>
<body>
<h1>Orbital</h1>
<canvas id="game-canvas"></canvas>
<h3>Instructions</h3>
<ul>
<li>1. Your LAUNCHPAD is represented by a green circle on the screen.</li>
<li>2. To launch a blue ship, click anywhere on the canvas.</li>
<li>3. The blue ship will leave the launchpad based on where you click!</li>
<li>4. Your click determines the direction and speed of the ball!</li>
<li>5. Try to get a blue ship to touch the red TARGET.</li>
<li>HINT: Your ships can bounce off of each other! This is required for some levels!</li>
</ul>
</body>
<script src="lib/keymaster.js"></script>
<script src="lib/movingObject.js"></script>
<script src="lib/util.js"></script>
<script src="lib/blackHole.js"></script>
<script src="lib/ship.js"></script>
<script src="lib/launchpad.js"></script>
<script src="lib/target.js"></script>
<script src="lib/game.js"></script>
<script src="lib/gameView.js"></script>
<script charset="utf-8">
var canvas = document.getElementById("game-canvas");
canvas.height = Orbital.Game.DIM_Y;
canvas.width = Orbital.Game.DIM_X;
var ctx = canvas.getContext('2d');
var game = new Orbital.Game();
var gameView = new Orbital.GameView(game,ctx);
var getMousePos = function (canvas, evt) {
var rect = canvas.getBoundingClientRect();
return {
x: (evt.clientX-rect.left)/(rect.right-rect.left)*canvas.width,
y: (evt.clientY-rect.top)/(rect.bottom-rect.top)*canvas.height
};
};
canvas.addEventListener("mousedown", function (event) {
var mousePos = getMousePos(canvas, event);
var x = mousePos.x;
var y = mousePos.y;
game.launchpad.launchShip(x,y);
}, false)
gameView.start();
</script>