Created
February 13, 2010 09:50
-
-
Save cflewis/303365 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rule "Reverse aliens if one reaches 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); | |
end | |
rule "Process bullets hitting aliens" | |
when | |
$shot : ShotEntity() | |
$alien : AlienEntity(this != $shot, eval($shot.collidesWith($alien))) | |
$otherAlien : AlienEntity() | |
then | |
game.getEntities().remove($shot); | |
game.getEntities().remove($alien); | |
$otherAlien.setHorizontalMovement($otherAlien.getHorizontalMovement() * 1.04); | |
end | |
rule "End the game when all aliens are killed" | |
salience 1 | |
when | |
not AlienEntity() | |
exists ShipEntity() | |
then | |
game.notifyWin(); | |
game.getEntities().clear(); | |
end | |
rule "End the game when an alien reaches the bottom" | |
when | |
exists AlienEntity(y > 570) | |
then | |
game.notifyDeath(); | |
game.getEntities().clear(); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment