2012-06-22 18:20:41 +02:00
|
|
|
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-22 18:20:41 +02:00
|
|
|
|
2012-06-24 10:50:26 +02:00
|
|
|
update: function(){
|
|
|
|
var ball = ig.game.getEntitiesByType( EntityBall )[0];
|
2012-06-22 18:20:41 +02:00
|
|
|
|
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-22 18:20:41 +02:00
|
|
|
}
|
|
|
|
|
2012-06-24 10:50:26 +02:00
|
|
|
this.parent();
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2012-06-22 18:20:41 +02:00
|
|
|
|
2012-06-24 10:50:26 +02:00
|
|
|
});
|