How to build a basic top down shooting game in Construct 2

Index

Attached Files

The following files have been attached to this tutorial:

.capx

tutorial-game-top-down-shooter.capx

Download now 111.46 KB

Stats

10,363 visits, 20,814 views

Translations

This tutorial hasn't been translated.

Tools

Building pretty (destructive) things.

NOTE: This tutorial is written under the assumption you already have downloaded Construct 2. In this tutorial I will be showing you how to build and design a basic top-down game using Construct 2.

Starting off and the first sprites

To start, open up a new file and add these 4 sprites. Make a player sprite and give it the 8 direction movement. Once you've done that make a second sprite and give it bullet movement (make sure to bring it's speed down a bit... If you dont it will race across the map like a, bullet)

Build a third sprite and give it the "Pin Ability." The fourth and final sprite will also have the pin ability. I've added a player image you could use below, BUT I strongly advise making your own images.)

You can make the player and enemy sprites out of the same images (NOTE: that the player already has a gun so you don't have to make a gun sprite in this case all you have to do is set the image point and change the spawn object action, Disregard any text about the gun sprite as it will not apply to you.)

Now name the sprites accordingly:

Sprite: Player

Sprite2: Enemy

Sprite3: PlayerGun

Sprite4: EnemyGun

Now draw what you think each of these should look like (Be creative and draw what you think the sprites should look like) Once you do that Put the player on one side of the map and the enemy on the other, then put the gun where the hands you drew on the player are. Same for the enemy.

The all powerful event sheet

Open up the events sheet now. You'll need to do 2 things, Make the event "On Start of layout" and give it the actions " Pin Gun to Player position and angle" and Pin EnemyGun to Enemy" After that add the global variable "Health" and "EnemyHealth" and assign them both values of 100.

Next add the event "Every tick" and the actions "Set Player angle to position, Mouse.X Mouse.Y" Once you have that Run the game and see what happens. If your character moves around and points to the mouse then your on the right track, else go over the events you have and figure out what you did wrong.

They're alive!!

Now we will make your character shoot and the enemy follow you around. This is pretty simple to do, simply use the same action we used to make the player follow the mouse but switch the " Mouse.X and Mouse.Y to Player.X and Player.Y and put it under the event "Every tick". and run the program again. Your player should now be getting stalked by the enemy.

Designing your weapons

To make it shoot just make a sprite, give it bullet movement, and destroy outside of layout, name it bullet, and make it look like a bullet. Add the "Mouse" object to the game and make a new event. "On left button clicked" then add the action "Gun spawn another object, Bullet" This will now allow your character to shoot but the bullets still don't do anything.

Here is a good image I picked up from a demo game.

Now add the events "Bullet on collision with enemy" and give it the action "Subtract 5 from EnemyHealth" and "Destroy Bullet" Now make the event "EnemyHealth <= 0" and give it the action "Destroy Enemy"

Test drive

Run the game and now you can destroy your enemy after you shoot it 20 times. Now add the event "Every 1.0 seconds" and give it the action "EnemyGun spawn another object, Bullet" and the enemy will shoot back at you. Run it again and test the game, try to destroy the enemy and see what happens. You may realize that the enemy can shoot you all he wants but the bullets just pass harmlessly through you.

Getting hurt

This is easy to do. Just take the "Bullet on collision with" event, and copy/paste it then tell it to affect the player instead of the enemy. (Ex. Subtract 5 from Health instead of EnemyHealth)

do the same with the "EnemyHealth <= 0" event and it's actions and reverse it to affect the player and there you go, your first fighting game. From here you can add solid walls, respawning enemies and a Game over and title screen. The sky (or your edition) is the limit!.

The finished masterpiece (sort of)

If all goes well and your computer doesn't spontaneously combust, the game should look a little like this. Notice I've added a simple background color, you can make it whatever you want but I've chosen green.

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!