How to build a space shooter with Ceilfire

This tutorial is gonna teach you how to build a space shooter using the Ceilfire game editor.

If you checked out the link above you will know that our game will have a spaceship which can be moved on the X-axis as well as enemies randomly spawning at the top of the world, who will then take their course towards the player ship to try and destroy it by crashing into it.

To help the player avoid a collision with the enemy ships they are equipped with an anti-spaceship missile launcher which will launch missiles towards the enemies in regular intervals.

As an added bonus we are going to add explosions when the enemy ships will crash into a missile or the player ship.

Getting started

Open the Ceilfire editor and create a new game. Change to the layers tab and select the existing layer. Change its name to background.

Now load an asset that will serve as the background for the game. You may create one by using this procedural space vista generator. Drag it onto the map and resize it so it slightly overlaps with the corners of the red-bordered camera-area.

Select the objects tab, then the object we just created and change its name to background using the properties bar.

step1, add background

Now open the asset store once more and either find or upload appropriate assets for

If you want to take one of these assets from a tileset, you may do so by

  • hovering Load and clicking As spritesheet
  • then adjust the number of rows and columns
  • click OK
  • drag the loaded asset into the map to create an object from the top left corner tile of the asset.

Now we need to create at least one object of each of the following types:

  • enemy
  • missile
  • spaceship

Just drag the appropriate assets into the map area to create one of each kind. Then change the names of all created objects to those given in the list above so you can use them in the rule editor later.

Now we have to add the following rules:

  • The player spaceship should be able to move left and right
  • The player spaceship should use its missile launcher to launch a missile towards the enemies every second
  • The player spaceship should explode on collision with enemies
  • The game should spawn enemies in a random position on the X-axis in regular intervals
  • Enemies should fly towards the player ship, i.e. downwards

To allow the spaceship to fly we add a control rule: Select the game object and click New event rule in the rule editor. Select the newly created rule and click New condition. Choose Key is down, press next, select If down-key is Leftand click on OK.

In the same rule click New action, select the player spaceship as action object and choose Set velocity X. Click next and enter a value like -150 as velocity value. This tells Ceilfire to move the player ship to the left as soon as the left arrow key will be pressed.

Add a new rule and repeat the process, this time selecting the key Right and entering 150 as velocity X.

You may now try to move the player spaceship by clicking Play and pressing either of the mentioned keys. Then stop the game using the stop button so we can continue building the game.

Now select the game object once more and add another rule to spawn missiles. As condition choose Every 1000 milliseconds and as action choose Player spaceship, then Spawn object and select Missile. This tells the game to spawn a missile at the player ship once every second.

Now add another action to the same rule. Select the missile object and Set Velocity Y to -200. This will send the missiles flying towards the top of the screen where the enemies are spawning.

A short introduction to animations

We will now create a simple animation which will be used in the next step to visualize an exploding spaceship.

Drag the animation asset, which has been loaded as a spritesheet (see begin of the tutorial) into the map area, but outside of the red borders, to create a basic animation object. Select it and change its name to explosion. In the objects tab click on the small button in the top right corner to open the animation editor. Click New to create a new animation. By default it will be given the name Animation0. You may click the Play button to see a preview of your animation. Press OK to close the animation editor.

The general process of playing an animation at a certain coordinate in the map is to

  • Create an animation object from a spritesheet
  • Create a new animation using the animation editor
  • Use the Spawn Object action in an event rule, selecting the animation object created in step 1
  • The animation object will spawn automatically when the rule is triggered
  • In the same rule, after the spawning of the animation object, add another action, select the animation object, and choose Play animation, then enter the name of the animation (e.g. Animation0).

explosion example in animation editor

Now select the enemy object and create one more rule. Choose Collides with… Player spaceship as condition. Add a new action and select the player spaceship, choose Spawn object and follow the instructions for playing back an animation, as explained above.

Repeat the process from the last paragraph, this time creating the explosion animation for the enemy object. Hint: Just select enemy instead of player spaceship

Now add two more actions to the same rule, selecting both player spaceshipand enemy once and choose Destroy. This will remove the two objects from the map when they will collide.

Unfortunately there are no enemies to play against yet, so let us quickly do something about this.

Select the game object and create another rule with the condition Every 750 milliseconds. As action choose Create object of type enemy. The coordinates should be randomized, so we will make use of the math library to generate a random coordinate:

For x-position, enter randomAB(20,800). This will generate a pseudo-random number between 20 and 800 which will then be used as the value for the x-coordinate. As y-position enter a value which will place the enemy ship close to the top, e.g. 50 (the top left corner has the coordinates [0;0]).

Save the game and click Play. You should see enemies spawning in random positions in the time interval specified earlier.

However we forgot to let the enemy ships fly, so Stop the game and select the enemy ship. Then go to the properties bar, open the Physics menu and set Enable body to No. In the velocity field, enter 0,100. This will make all enemy objects spawn with the vertical velocity preset to 100 distance units per time unit.

Save and Play once more to confirm that everything is working. You might notice how enemy spaceships do not detonate on impact of the player ship’s missiles. Adding this rule will be left as an exercise to you. If you need help creating the rule, just have a peek at the following image.

In case you have problems following this tutorial at any point, feel free to remake the tutorial game to load the tutorial game and examine it using the editor!

You should now be able to create your very own space shooter and similar games. Why not expand the game by implementing the following changes?

  • Add an explosion sound which is being played when spaceships explode
  • Add a mysterious space vibe soundtrack
  • Add a Game over message when the player spaceship gets destroyed
  • Add a control rule that will allow the player to shoot missiles by pressing a certain button.

Leave a Reply

Your email address will not be published. Required fields are marked *