File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020
2121 < script src ="js/starfield.js "> </ script >
2222 < script src ="js/spaceinvaders.js "> </ script >
23- < script >
24-
25- // Create the starfield.
26- var container = document . getElementById ( 'starfield' ) ;
27- var starfield = new Starfield ( ) ;
28- starfield . initialise ( container ) ;
29- starfield . start ( ) ;
30-
31- // Setup the canvas.
32- var canvas = document . getElementById ( "gameCanvas" ) ;
33- canvas . width = 800 ;
34- canvas . height = 600 ;
35-
36- // Create the game.
37- var game = new Game ( ) ;
38-
39- // Initialise it with the game canvas.
40- game . initialise ( canvas ) ;
41-
42- // Start the game.
43- game . start ( ) ;
44-
45- // Listen for keyboard events.
46- window . addEventListener ( "keydown" , function keydown ( e ) {
47- var keycode = e . which || window . event . keycode ;
48- // Supress further processing of left/right/space/a/d/w/up (37/29/32/65/68/87/38)
49- if ( keycode == 37 || keycode == 39 || keycode == 32 || keycode == 65 || keycode == 68 || keycode == 87 || keycode == 38 ) {
50- e . preventDefault ( ) ;
51- }
52- game . keyDown ( keycode ) ;
53- } ) ;
54- window . addEventListener ( "keyup" , function keydown ( e ) {
55- var keycode = e . which || window . event . keycode ;
56- game . keyUp ( keycode ) ;
57- } ) ;
58-
59- function toggleMute ( ) {
60- game . mute ( ) ;
61- document . getElementById ( "muteLink" ) . innerText = game . sounds . mute ? "Unmute" : "Mute" ;
62- }
63- </ script >
23+ < script src ="js/setup.js "> </ script >
6424 < script type ="text/javascript ">
6525
6626 var _gaq = _gaq || [ ] ;
Original file line number Diff line number Diff line change 1+ // Create the starfield.
2+ var container = document . getElementById ( 'starfield' ) ;
3+ var starfield = new Starfield ( ) ;
4+ starfield . initialise ( container ) ;
5+ starfield . start ( ) ;
6+
7+ // Setup the canvas.
8+ var canvas = document . getElementById ( "gameCanvas" ) ;
9+ canvas . width = 800 ;
10+ canvas . height = 600 ;
11+
12+ // Create the game.
13+ var game = new Game ( ) ;
14+
15+ // Initialise it with the game canvas.
16+ game . initialise ( canvas ) ;
17+
18+ // Start the game.
19+ game . start ( ) ;
20+
21+ // Listen for keyboard events.
22+ window . addEventListener ( "keydown" , function keydown ( e ) {
23+ var keycode = e . which || window . event . keycode ;
24+ // Supress further processing of left/right/space/a/d/w/up (37/29/32/65/68/87/38)
25+ if ( keycode == 37 || keycode == 39 || keycode == 32 || keycode == 65 || keycode == 68 || keycode == 87 || keycode == 38 ) {
26+ e . preventDefault ( ) ;
27+ }
28+ game . keyDown ( keycode ) ;
29+ } ) ;
30+
31+ window . addEventListener ( "keyup" , function keydown ( e ) {
32+ var keycode = e . which || window . event . keycode ;
33+ game . keyUp ( keycode ) ;
34+ } ) ;
35+
36+ function toggleMute ( ) {
37+ game . mute ( ) ;
38+ document . getElementById ( "muteLink" ) . innerText = game . sounds . mute ? "Unmute" : "Mute" ;
39+ }
You can’t perform that action at this time.
0 commit comments