uberpong/dev/lib/game/entities/paddle-player.js
2013-04-25 22:18:37 +02:00

49 lines
1.1 KiB
JavaScript

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]);
},
update: function(){
this.currentAnim =
this.anims['lives'+ig.global.lifes];
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;
}
this.parent();
}
});
});