|
4 | 4 | <title>Space Invaders</title> |
5 | 5 | <link rel="stylesheet" type="text/css" href="css/core.css"> |
6 | 6 | <link rel="stylesheet" type="text/css" href="css/typeography.css"> |
7 | | - <style> |
8 | | - |
9 | | - /* Styling needed for a fullscreen canvas and no scrollbars. */ |
10 | | - body, html { |
11 | | - width: 100%; |
12 | | - height: 100%; |
13 | | - margin: 0; |
14 | | - padding: 0; |
15 | | - overflow: hidden; |
16 | | - } |
17 | | - |
18 | | - #starfield { |
19 | | - width:100%; |
20 | | - height:100%; |
21 | | - z-index: -1; |
22 | | - position: absolute; |
23 | | - left: 0px; |
24 | | - top: 0px; |
25 | | - } |
26 | | - #gamecontainer { |
27 | | - width: 800px; |
28 | | - margin-left: auto; |
29 | | - margin-right: auto; |
30 | | - } |
31 | | - #gamecanvas { |
32 | | - width: 800px; |
33 | | - height: 600px; |
34 | | - } |
35 | | - #info { |
36 | | - width: 800px; |
37 | | - margin-left: auto; |
38 | | - margin-right: auto; |
39 | | - } |
40 | | - </style> |
| 7 | + <link rel="stylesheet" type="text/css" href="css/game.css"> |
41 | 8 | </head> |
42 | 9 | <body> |
43 | 10 | <div id="starfield"></div> |
|
53 | 20 |
|
54 | 21 | <script src="js/starfield.js"></script> |
55 | 22 | <script src="js/spaceinvaders.js"></script> |
56 | | - <script> |
57 | | - |
58 | | - // Create the starfield. |
59 | | - var container = document.getElementById('starfield'); |
60 | | - var starfield = new Starfield(); |
61 | | - starfield.initialise(container); |
62 | | - starfield.start(); |
63 | | - |
64 | | - // Setup the canvas. |
65 | | - var canvas = document.getElementById("gameCanvas"); |
66 | | - canvas.width = 800; |
67 | | - canvas.height = 600; |
68 | | - |
69 | | - // Create the game. |
70 | | - var game = new Game(); |
71 | | - |
72 | | - // Initialise it with the game canvas. |
73 | | - game.initialise(canvas); |
74 | | - |
75 | | - // Start the game. |
76 | | - game.start(); |
77 | | - |
78 | | - // Listen for keyboard events. |
79 | | - window.addEventListener("keydown", function keydown(e) { |
80 | | - var keycode = e.which || window.event.keycode; |
81 | | - // Supress further processing of left/right/space/a/d/w/up (37/29/32/65/68/87/38) |
82 | | - if(keycode == 37 || keycode == 39 || keycode == 32 || keycode == 65 || keycode == 68 || keycode == 87 || keycode == 38) { |
83 | | - e.preventDefault(); |
84 | | - } |
85 | | - game.keyDown(keycode); |
86 | | - }); |
87 | | - window.addEventListener("keyup", function keydown(e) { |
88 | | - var keycode = e.which || window.event.keycode; |
89 | | - game.keyUp(keycode); |
90 | | - }); |
91 | | - |
92 | | - function toggleMute() { |
93 | | - game.mute(); |
94 | | - document.getElementById("muteLink").innerText = game.sounds.mute ? "unmute" : "mute"; |
95 | | - } |
96 | | - </script> |
97 | | - <script type="text/javascript"> |
98 | | - |
99 | | - var _gaq = _gaq || []; |
100 | | - _gaq.push(['_setAccount', 'UA-41728580-1']); |
101 | | - _gaq.push(['_trackPageview']); |
102 | | - |
103 | | - (function() { |
104 | | - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; |
105 | | - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; |
106 | | - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
107 | | - })(); |
108 | | - |
109 | | -</script> |
| 23 | + <script src="js/setup.js"></script> |
110 | 24 | </body> |
111 | 25 | </html> |
0 commit comments