uberpong/dev/lib/game/entities/paddle-player.js

49 lines
1.1 KiB
JavaScript
Raw Normal View History

ig.module(
'game.entities.paddle-player'
)
.requires(
'impact.entity'
)
.defines(function(){
EntityPaddlePlayer = ig.Entity.extend({
size: {x: 30, y: 120},
collides: ig.Entity.COLLIDES.FIXED,
type: ig.Entity.TYPE.A,
name: 'paddle-player',
animSheet: new ig.AnimationSheet('media/paddle-player_sheet.png', 30, 120),
maxVel: {x: 0, y: 400},
init: function(x, y, settings) {
this.parent(x, y, settings);
this.addAnim('idle', 1, [0]);
this.addAnim('lives4', 1, [0]);
this.addAnim('lives3', 1, [1]);
this.addAnim('lives2', 1, [2]);
this.addAnim('lives1', 1, [3]);
this.addAnim('lives0', 1, [4]);
},
2012-07-06 17:09:07 +02:00
update: function(){
this.currentAnim =
this.anims['lives'+ig.global.lifes];
2012-07-06 17:09:07 +02:00
if (ig.input.state('up')) {
this.vel.y = -400;
} else if (ig.input.state('down')) {
this.vel.y = 400;
} else if (ig.input.state('force-top')) {
this.pos.y = 48;
} else if (ig.input.state('force-bottom')) {
this.pos.y = 240;
} else {
this.vel.y = 0;
}
2012-07-06 17:09:07 +02:00
this.parent();
}
});
2012-06-24 10:50:26 +02:00
});