26 lines
406 B
JavaScript
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();
|
|
}
|
|
|
|
});
|
|
|
|
});
|