Star Defender

Blast the aliens before they reach you. Star Defender shows how to create objects from a rule, how chasing works, and how an explosion cleans itself up.

Star Defender — NutHouse
The Star Defender level: a spaceship at the bottom of a starry space background, with two spawners above the top edge
Two spawners sit above the level and drop aliens in.

What it shows

Shows: Creating objects, chasing, explosions. The level’s Gravity pulls is Off, so nothing falls unless a movement moves it.

How to play

← and → slide the ship. Space fires a laser. Blob aliens drift down and are worth 10. Flying saucers come every six seconds, chase you, and are worth 50. Let an alien touch the ship and you lose a life. At zero lives, Play again appears.

The things in it

SpaceshipArrow keys (8 directions), Left/Right only, Speed 60.
LaserBouncing ball, Speed 90, starts moving up. None are in the level at the start: rules create them.
Blob AlienBouncing ball, Speed 12, starts moving downwards, Wobble when bouncing 20.
Flying SaucerChases another object: Spaceship, Speed 14, Only when closer than 0 (always).
ExplosionStays still. Its stopped animation plays once and does not repeat.
Alien Maker, Saucer MakerSpawners. Blobs Every 1.2 seconds, saucers Every 6, both with Wander across 280.
Score, Lives, Game Over, Play AgainThe last two start hidden.

The rules, one by one

Star Defender — Events
The Events tab of Star Defender
Twelve rules in four groups.
WhenUpon pressing SpaceSpaceship is visible
DoCreate Laser at 0, −24 from SpaceshipPlay Jump

The laser appears 24 pixels above the ship and flies up by itself. “Is visible” stops you shooting after game over, when the ship is hidden.

WhenSpaceship leaves the play area (left, right)
DoStop Spaceship
WhenLaser leaves the play area (top)
DoDestroy Laser
WhenBlob Alien leaves the play area (left, right)
DoBounce Blob Alien

Lasers that miss are tidied away. Blobs bounce off the sides.

WhenBlob Alien is completely outside the play areaBlob Alien: Y > 480
DoDestroy Blob Alien

A blob that drifts off the bottom is destroyed. Y > 480 makes sure it is below the level, not above it where it has only been made.

WhenLaser collides with Blob Alien
DoCreate Explosion at 0, 0 from Blob AlienDestroy Blob AlienDestroy LaserAdd 10 to the scorePlay Explosion

The explosion is made first, on top of the blob, and then the blob and the laser go.

WhenSpaceship collides with Blob Alien
DoDestroy Blob AlienSubtract 1 from the livesFlash Spaceship for 1 secondShake the screenPlay Hit

A hit on the ship. The screen shakes with strength 8 for half a second.

WhenLaser collides with Flying Saucer
DoCreate Explosion at 0, 0 from Flying SaucerDestroy Flying SaucerDestroy LaserAdd 50 to the scorePlay Explosion
WhenSpaceship collides with Flying Saucer
DoDestroy Flying SaucerSubtract 1 from the livesFlash Spaceship for 1 secondShake the screenPlay Hit

The same two rules again for saucers, with bigger points.

WhenExplosion: animation “stopped” has finished
DoDestroy Explosion

The explosion removes itself when its pictures run out. See An explosion that cleans itself up.

WhenLives = 0Spaceship is visible
DoHide SpaceshipAlien Maker: Stop spawningSaucer Maker: Stop spawningShow Game OverShow Play Again

“Is visible” makes this happen only once. After the ship is hidden, the rule is no longer true.

WhenPlay Again is clicked
DoRestart the game

Three changes to try

  1. No machine guns. Right-click the number of rule 1 and choose Add another condition…. Pick ⚙ Special → Not more than once every… and type 0.3. Now the ship fires three times a second at most.
  2. Saucer swarm. In the Level tab click Saucer Maker in the sidebar and change Every (seconds) from 6 to 2.
  3. Faster blobs. Click a Blob Alien and change Speed from 12 to 20.

Still stuck?

Try the Chocobreak tutorial, open a sample game and read its rules, or look at the questions people ask.