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

27 lines
406 B
JavaScript
Raw Normal View History

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