Add high performance features, see #12

This commit is contained in:
Aaron Mueller 2012-07-06 17:09:07 +02:00
parent 76679d9a99
commit 7b40c7adb1
3 changed files with 20 additions and 19 deletions

View file

@ -5,25 +5,24 @@ ig.module(
'game.entities.paddle' 'game.entities.paddle'
) )
.defines(function(){ .defines(function(){
EntityPaddlePlayer = EntityPaddle.extend({ EntityPaddlePlayer = EntityPaddle.extend({
animSheet: new ig.AnimationSheet( 'media/paddle-player.png', 30, 96 ), animSheet: new ig.AnimationSheet( 'media/paddle-player.png', 30, 96 ),
update: function(){ update: function(){
if (ig.input.state('up')) { if (ig.input.state('up')) {
this.vel.y = -400; this.vel.y = -400;
} } else if (ig.input.state('down')) {
else if( ig.input.state('down') ) {
this.vel.y = 400; this.vel.y = 400;
} } else if (ig.input.state('force-top')) {
else { this.pos.y = 48;
} else if (ig.input.state('force-bottom')) {
this.pos.y = 240;
} else {
this.vel.y = 0; this.vel.y = 0;
} }
this.parent(); this.parent();
} }
});
}); });
});

View file

@ -9,7 +9,7 @@ ig.module(
EntityPaddle = ig.Entity.extend({ EntityPaddle = ig.Entity.extend({
name: 'paddle', name: 'paddle',
scores: 0, scores: 0, // TODO: whats this?
size: {x: 30, y: 96}, size: {x: 30, y: 96},
collides: ig.Entity.COLLIDES.FIXED, collides: ig.Entity.COLLIDES.FIXED,

View file

@ -23,6 +23,8 @@ ig.module(
ig.input.bind(ig.KEY.ESC, 'mainmenu'); ig.input.bind(ig.KEY.ESC, 'mainmenu');
ig.input.bind(ig.KEY.UP_ARROW, 'up'); ig.input.bind(ig.KEY.UP_ARROW, 'up');
ig.input.bind(ig.KEY.DOWN_ARROW, 'down'); ig.input.bind(ig.KEY.DOWN_ARROW, 'down');
ig.input.bind(ig.KEY.T, 'force-top');
ig.input.bind(ig.KEY.B, 'force-bottom');
// vim goodness // vim goodness
ig.input.bind(ig.KEY.K, 'up'); ig.input.bind(ig.KEY.K, 'up');
ig.input.bind(ig.KEY.J, 'down'); ig.input.bind(ig.KEY.J, 'down');