
rule "Reverse aliens if one reachs the edge of the screen"when$alien : AlienEntity()exists (AlienEntity(x < 10) or AlienEntity(x > 750))then$alien.setHorizontalMovement(-$alien.getHorizontalMovement());$alien.setY($alien.getY() + 10);endrule "Process bullets hitting aliens"when$shot : ShotEntity()$alien : AlienEntity(this != $shot, eval($shot.collidesWith($alien)))$otherAlien : AlienEntity()thengame.getEntities().remove($shot);game.getEntities().remove($alien);$otherAlien.setHorizontalMovement($otherAlien.getHorizontalMovement() * 1.04);endrule "End the game when all aliens are killed"salience 1whennot AlienEntity()exists ShipEntity()thengame.notifyWin();game.getEntities().clear();endrule "End the game when an alien reaches the bottom"whenexists AlienEntity(y > 570)thengame.notifyDeath();game.getEntities().clear();end
ref:



No hay comentarios:
Publicar un comentario