xonecas.io
211
Ze

zen / commit 1c0b3e0

starting to change to a single game loop

xonecas2011-02-15 1c0b3e00498b1d6533ff66a0038c53fc15f3b75a parent 920d914

2 files changed

index.html+1−0
@@ -51,6 +51,7 @@
5151 </script>
5252
5353 <!-- scripts concatenated and minified via ant build script-->
54+
5455 <script src="js/plugins.js"></script>
5556 <script src="js/script.js"></script>
5657 <!-- end concatenated and minified scripts-->
js/script.js+6−4
@@ -169,7 +169,7 @@
169169 direction: 1,
170170
171171 init: function (size, ctx, type) {
172- this._super(size, size, ctx, get(type));
172+ this._super(size, size, ctx, get(type+this.face));
173173 this.direction = -1;
174174 },
175175
@@ -182,6 +182,7 @@
182182 },
183183
184184 // give some dancing abilities to the invaders
185+/*
185186 live: function (x, y) {
186187 this.x = x;
187188 this.y = y;
@@ -201,8 +202,11 @@
201202 }) ();
202203
203204 },
205+*/
204206
205207 move: function (direction) {
208+ this.fill = get('skully'+ this.face);
209+ this.face = (this.face === '1')? '2': '1';
206210 this.moving = true;
207211 this.clear();
208212 this.x += IMGSIZE * direction;
@@ -248,7 +252,7 @@
248252 while (cols--) {
249253 index = this.invaders.push(new Invader(IMGSIZE, this.ctx, 'skully')) -1;
250254 var invader = this.invaders[index];
251- invader.live(x, y);
255+ invader.draw(x, y);
252256 x += IMGSIZE + PADSIZE;
253257 }
254258 y += IMGSIZE + PADSIZE;
@@ -332,8 +336,6 @@
332336 $('body').append(canvas);
333337 var game = new SpaceInvaders(canvas);
334338
335- // this works, but I don't fully understand
336- // why I had to call it like that...
337339 document.onkeydown = function (ev) {
338340 game.keydown.call(game, ev);
339341 }