Top-down shooter
The Top-down shooter template is a streamlined version of the Ghost Shooter tutorial.
The player controls a Player object with the arrow keys of the keyboard or with the W,A,S and D keys thanks to the Keyboard plugin. With the Mouse plugin, the player points the direction in which the Player object is to aim and pressing down the left button does shoot Bullets 10 times in a second.
The Bullets, when hitting Enemies, cause damage and end up destroying them.
The Player uses the behavior 8direction for the movement. As with Platform or Car, 8direction does have “Default controls” (arrow keys) which will automatically move the object it is applied to in the pressed direction.
In addition, 8direction can be set to move in only certain directions (like the up & down option which means the object would only move to the top or the bottom of the screen and in no other direction).
We can also set the angle of the object accordingly to the “Set angle” property, using only increments or the whole actual 360°.
8direction also interacts with the Solid behavior, although this interaction is not used in this template.
The Player also has the ScrollTo behavior to keep the “camera” on the Player at all times.
The Player is also BoundToLayout to prevent moving out of the layout and always stay visible on the screen.
The Bullet object has the Bullet behavior to be able to move “on its own”.
It also contains the DestroyOutsideLayout behavior which will destroy it as soon as the Bullet object is out of the boundaries of the layout.
This prevents having Bullets flying forever and cluttering the device’s memory once they cannot interact with the game’s world anymore.
Notice how the Bullet instance in the Layout is positioned outside of the layout already.
On execution, it will be destroyed right away without requiring any event or other types of maintenance to do so.
In event 2, Bullets are spawned from the Player (they are created to its position).
Notice the action “Bullet: Rotate random(-4, 4) degrees clockwise.
This action uses the expression Random().
Random(a,b) will return a random value between the number a and up to but not equal to b.
In events, expressions are used to calculate sums or retrieve information from objects, such as a Sprite's X co-ordinate.
This modifies the angle the Bullet is moving at, giving a little randomness to the shooting.
This “juices” up your game adding a fun element, a mastered randomness to this base gameplay element.
This template has no winning or death conditions.