uberpong/dev/lib/game/entities/paddle-enemy.js
2012-06-24 10:50:26 +02:00

26 lines
406 B
JavaScript

ig.module(
'game.entities.paddle-enemy'
)
.requires(
'game.entities.ball',
'game.entities.paddle'
)
.defines(function(){
EntityPaddleEnemy = EntityPaddle.extend({
update: function(){
var ball = ig.game.getEntitiesByType( EntityBall )[0];
if( ball.pos.y + ball.size.y / 2 > this.pos.y + this.size.y / 2 ) {
this.vel.y = 100;
} else {
this.vel.y = -100;
}
this.parent();
}
});
});