Top Down Shooter - Part 5
This tutorial explains to you how to create a Top-Down Shooter game in GDevelop. If you are a beginner or you have never used GDevelop before, this might be a great place to begin.
In this tutorial, you will learn how to :
- Make an obstacle for our Enemy
- Animate a sprite
- Optimize the game by deleting unnecessary objects
Series
You are reading Part 5 of the Top-Down Shooter Tutorial. If you haven't read Part 4, then you can read it by selecting it down below.
This tutorial will help you to begin to use GDevelop. You will create a top-down shootergame where the player shoots and kills the enemy. Note that you can read the Getting Started page to get an overview of the software. It explains the main concepts and describes the interface of GDevelop.
Previously
In Part 3 we made an Enemy, a Health Bar, and a shooting Gun. So, today we are going to make an obstacle for our Enemy and make an Enemy which shoots our Player.
Step 1. Obstacle for our Enemy
Making an obstacle for our Enemy is very important. This is a must when you want to create a map. To create it:
- Add a new object
- Select Tiled Sprite
- Name it "Wall"
- Select Wall_1.png
- Go to the Behavior tab
- Click on Add a new behavior
- Select Pathfinding Obstacle
- Click on OK
- Now, right-click on the Wall
- Click on duplicate
- Rename it Wall 2
- Now double click on it to open Object Editor
- Right-click over the frame and click on delete to delete the frame
- Now click on Add
- Select Wall 2 1 asset
- Click on OK
- Now drag it over the scene
We have made two different walls now we net to keep it as a group. To do that:
- Open the Group Editor (If not opened)
- Click on Add a new group
- Name the group Wall
- Double click on Wall to open group Editor
- In the Object name right Wall 1 and click on the Enter key
- Do the same by writing wall 2
Now, we have our obstacle for the Enemy. But, we also don't want Player to pass through things that the Enemy can't. To do that:
- Add a new action
- Select Player
- Select Separate objects
- Choose Wall
- Click on OK.
Step 2. Animate our Player
We know that our Player has 2 animations. But only the first one is Played. We want the second one to play when the Player is moving. And to do so:
- Go to the Events tab
- Add a new Event
- Add a new condition
- Select Player
- Select Is moving
- Click on OK
- Now, add a new action
- Select Player
- Select Change the animation
- Choose = as the operator sign
- Write 1 in the value
- Click on OK
Now the animation changes when we move but doesn't change to 1 when we stop. To do that:
- Add a new Event
- Add a new condition
- Select Player
- Select Is moving
- Now, click on OK
- After that hover over that condition and use the right mouse button
- Click on Invert Condition
- Now add a new action
- Select Player
- Choose = as the operator sign
- Write 0 in the value
- Click on OK
Step 3. Optimize for better performance
We need to optimize our game for a better performance. To do that, we can delete unnecessary objects like Bullet. When we miss our target, we have to make sure that the Bullet doesn't just keep going and going, it should be deleted. To do that we have a Behavior called Destroy Outside the Screen. To use that:
- Double click on Bullet to open the Object Editor
- Go to the Behavior tab
- Click on Add a new Behavior
- Select Destroy Outside the Screen
- Click on OK
Conclusion
In this part, We learned how to Optimize our game for better Performance. We also learned how to animate a sprite and make an obstacle for our Enemy.