<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.shootemupkit.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Building_the_Asteroids_Template</id>
	<title>Building the Asteroids Template - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.shootemupkit.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Building_the_Asteroids_Template"/>
	<link rel="alternate" type="text/html" href="https://www.shootemupkit.com/wiki/index.php?title=Building_the_Asteroids_Template&amp;action=history"/>
	<updated>2026-04-09T07:08:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://www.shootemupkit.com/wiki/index.php?title=Building_the_Asteroids_Template&amp;diff=133&amp;oldid=prev</id>
		<title>Wikiadmin: Created page with &quot;===Templates===   This tutorial explains how we built the ''Asteroids'' template.  The template is included ready-made in the ''Shoot 'em Up Kit'' and you can Create from a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.shootemupkit.com/wiki/index.php?title=Building_the_Asteroids_Template&amp;diff=133&amp;oldid=prev"/>
		<updated>2020-05-24T14:05:56Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;===Templates===   This tutorial explains how we built the &amp;#039;&amp;#039;Asteroids&amp;#039;&amp;#039; template.  The template is included ready-made in the &amp;#039;&amp;#039;Shoot &amp;#039;em Up Kit&amp;#039;&amp;#039; and you can Create from a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;===Templates===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This tutorial explains how we built the ''Asteroids'' template.  The template is included ready-made in the ''Shoot 'em Up Kit'' and you can [[Create from a Template|create a new game using it as a starting point]].  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Build the Game===&lt;br /&gt;
&lt;br /&gt;
Create a new Empty Project&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids1.jpg|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Give the project a name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select ''2D with models''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click the ''OK'' button to create the project.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids2.jpg|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select the [[Level Editor|Level Editor]]&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids3.jpg|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The scene is empty except for a single directional [[Add a Light|light]].  A grid to help visualise the area is shown.  Because we selected to create a 2D game the objects we place will be placed on this plane by default.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The first thing we will add to the scene is a [[Add a Player|ship for the player]] to control.  Click on the [[File:ToolsMenu02.png|link=]]''Player'' button and select ''Drone 02''.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids4.jpg|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then place the ship somewhere near the centre of the screen.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids5.jpg|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the Player ship and the [[Player General Tab|''Properties'']] window will open.  Scroll down the properties window until you see the [[Player Definition |''Player Definition'']], [[Input Definition|''Input Definition'']] and [[Movement Definition|''Movement Definition'']].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Define Menu|Definitions]] are a small collection of properties that you can tweak for you project.  The [[Player Definition |Player Definition]], for example, has properties such as the number of lives, Health, and how long the player is invulnerable at the start of a game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can apply the same Definitions to multiple items in the scene.  For example, you can have an [[NPC Definition|NPC Definition]] shared by all the [[Add an NPC|NPCs]] in a formation so that each NPC has the same health – and tweaking the NPC definition will affect all the NPCs which are using it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For making an asteroid shooter we need to change the [[Input Definition|Input Definition]], which specifies what action each input button or axis performs.  We also need to change the [[Movement Definition|Movement Definition]] to use rotational movement.  And finally, we will change the [[Player Definition |Player Definition]] to allow 2 seconds of invulnerability after the player spawns or respawns into the level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the [[Input Definition|Input Definition]], which is currently set to Horizontal + Fire.  Select ''Rotate Yaw + Fw &amp;amp; Bk''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the Movement Definition and select ''Rotation'' from the list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the Player Definition and select ''Invulnerable 2s'' from the list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the classic Asteroids game, the ship can only move forwards.  It uses a thruster to set momentum and keep the ship moving.  We’ll use a simplified version for this tutorial.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will modify the ''Rotate Yaw + Fw &amp;amp; Bk'' [[Input Definition|Input Definition]] to modify some of the controls.  To do this, click the arrow next to the Input definition to go straight to the definition.  Alternatively, you can open the Input Definition list from the [[Define Menu|Define menu]] and select the ''Default'' definition.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids6.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select the ''Left Analog -Y'' property that is currently set to ''Move Backwards''.  Change this to ''Unused'' so that the ship can no longer move backwards.  Click the ''OK'' button and close the definition list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The ship currently rotates quite slowly so we will alter the [[Movement Definition|movement definition]] to speed up the rotation.  With the Player selected, and the [[Player General Tab|General properties window]] open, go to the [[Movement Definition|Movement Definition]] and click the arrow to go straight to the ''Rotate'' movement definition.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids7.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Increase the ''Max Rotation Speed'' to 4.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Active Area'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We want to limit the player to an area of the map so that we can generate asteroids outside of this area and let them move across as a hazard to the player.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the [[File:ToolsMenu10.png|link=]]Trigger icon on the [[Tools Menu|Tools pane]] and place it next to the player&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Set the Name to ''Play Area''&lt;br /&gt;
&lt;br /&gt;
Set the Shape to ''Box''&lt;br /&gt;
.&lt;br /&gt;
Set the ''Size'' to X: 300 and Y: 300.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids8.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To limit the player’s movement to the active area we need to select the player again.  In the [[Player General Tab|properties window]] set the ''Active Area'' to ''Play Area'' and the ''Area Action'' to ''Wrap''.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids9.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Creating Asteroids'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Asteroids will be created using an [[Add an NPC Generator|NPC Generator]].  An NPC Generator can spawn non-player characters (NPCs), which is this game will be asteroids.  The asteroids will be spawned at NPC Generator nodes that we will place around the edge of the active area.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the [[File:ToolsMenu04.png|link=]] NPC Generator button on the [[Tools Menu|Tools pane]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select ''Boulder 01'' and double click it or press the ''OK'' button.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids10.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Place a few nodes around the outside of the play area by clicking on the map.  Three or four is probably enough as their direction will be randomised.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can [[Level Editor#Moving Around the Level|zoom the map in or out]] using the mouse wheel to help visualise placement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you’ve placed a few nodes click the ''Stop Placing'' button or press ''Esc''.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids11.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the template game we have created three nodes all along the right-hand side of the playing area.  Because the directions will be randomised, and the active area will wrap items from one side of the map to the other, it is alright to just place the [[Add an NPC Generator|NPC Generator]] nodes along one edge.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids12.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will now set-up the NPC Generator to spawn asteroids at the rate we want and to use the active area we created in a previous step.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids13.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, we will set [[Movement Definition|Movement Definition]] to ''Linear Axis''.  Open the ''Linear Axis'' definition and change movement to ''Linear Proportional'' (to do this, click the arrow next to the Movement definition in the [[NPC Generator General Tab|properties window]] or open the Movement Definition list from the [[Define Menu|Define menu]] and select the ''Linear Axis'' definition).  This will allow the asteroids to move in full 360 degrees.  AI uses virtual input to steer the asteroid just like the player does to steer the ship.  If we use proportional input, then the AI’s virtual joystick can move in fine detail and the asteroid can move in many directions.  If we use linear directions, then the virtual joystick will be limited to extreme X and/or Y which would limit the asteroid to 8 directions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Set ''Active Area'' to ''Play Area'', which is the Trigger/Active area we created earlier.&lt;br /&gt;
&lt;br /&gt;
Set ''Area Action'' to ''Wrap''.  This will allow the asteroids to wrap from one side of the active area to the other.&lt;br /&gt;
&lt;br /&gt;
Set the ''Min Spawn Time'' to 2 and the ''Max Spawn Time'' to 4.  This will spawn each new asteroid at a random time between 2 and 4 seconds.&lt;br /&gt;
&lt;br /&gt;
Set the ''Max Can Generate'' to 8.  This will restrict the NPC Generator to spawning 8 asteroids.  Feel free to play around with this number.  Small values make the game easier and greater values will make the game very chaotic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Asteroid AI Behaviours'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click the [[AI Tab|AI tab]] so that we can set the AI behaviours for the asteroid.  This will be limited to moving in a randomised direction and rotating to provide a visual effect.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids14.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Change the ''AI Type'' to ''Move Random''.  Several new options will appear.&lt;br /&gt;
&lt;br /&gt;
Set the ''Plane'' to ''XY''&lt;br /&gt;
&lt;br /&gt;
Set ''Change Dir Time (Min)'' to 99999 and ''Change Dir Time (Max)'' to 99999.  This will prevent the asteroids from changing direction.  They will change direction after 99,999 seconds but as this is over 1 day we can safely assume no-one will see this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add another ''AI Typ''e by clicking the ''Add A.I. Behaviour'' button.  We will add some rotation to the asteroids to make them more interesting.&lt;br /&gt;
&lt;br /&gt;
Set the ''AI Type'' to ''Rotate +Pitch''.&lt;br /&gt;
&lt;br /&gt;
Leave the ''Speed Multiplier'' property at 1.0 as this is a good speed for the rotation effect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Keeping the NPCs (Asteroids) active'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With any NPC Generator node active, go to the [[NPC Generator General Tab|General pane]] and find the [[NPC Definition|NPC Definition]].  Click the button next to ''Axis Movement'' to go to the NPC Definition.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Uncheck the option ''Disable when leaving Camera'' to prevent the asteroids from being removed when they leave the screen.  We want them to stay active so that wrap around the playing area back onto the other side.&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
[[File:Asteroids15.png|link=]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''Add a Camera''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Select the [[File:ToolsMenu06.png|link=]] [[Add a Camera|Camera]] from the [[Tools Menu|Tools pane]].  Move the green target icon into the centre of the playing area, where the player is, and click to place the camera.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
All the defaults for the camera should be good.  The camera will be positioned 200 units back, which should be a good distance.  We don’t need the camera to move or track the player and so we can just test the level and see the new camera in action.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Improve the Game===&lt;br /&gt;
&lt;br /&gt;
[[Add an NPC Generator|Add smaller boulders]] (scale them down) and make them faster by creating a new [[Movement Definition|Movement Definition]] type (Copy the ''Axis Movement'' Definition, give it a new ''name'', and increase the ''Max Speed'').&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Add an NPC Generator|Add an NPC Generator]] that spawns an enemy ship that can fire at the player.  Try new [[AI Tab|AI behaviours, such as setting the ship to ''chase'' the player or perhaps use ''Move Random'' but set the ''Min'' and ''Max'' change direction values to 2 and 5, and use an ''Area Action'' of ''Destroy Self''.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add thrust to the ship (in the [[Input Definition|Input Definition]]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Background Settings|Add movement to the background]].  Make it slowly rotate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Speed up the rotation of the ship (in the [[Movement Definition|Movement Definition]]).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add thrust particle [[Effects Tab|effects]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add Post Processing effects in [[Level Settings|Level Settings]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add a [[Shield Definition|shield]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add Hyperspace&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Spawn asteroids that take 2 or more shots to destroy by changing the [[NPC Definition|health]] and [[Weapon Definition|projectile damage]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add [[Upgrade Definition|upgrades]] to fire multiple shots or higher-powered weapons.&lt;/div&gt;</summary>
		<author><name>Wikiadmin</name></author>
		
	</entry>
</feed>