This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:tutorials:platformer:part-7 [2020/09/23 10:35]
gdevelop5:tutorials:platformer:part-7 [2020/12/26 13:56] (current)
Line 1: Line 1:
-# Platformer Tutorial, Part 7: Add Checkpoints to the Game+# Platformer Tutorial, Part 7: Make Enemies Kill the Player (and the Player Kill the Enemies)
-## Step 1: Create an object for the checkpoint+This part of the tutorial explains how the player can kill -- and be killed by -- the game's enemies.
-1. Create a [Sprite](#) object named "Checkpoint"+## Series
-2. Add an image to the object that represents the checkpoint. +
-3. Drag one or more instances of the object into the scene.+
-## Step 2Save the player's coordinates when they collide with the checkpoint+You are reading **Part 7** of the [[gdevelop5:tutorials:platformer:start|Platformer Tutorial]]. 
 +1. [[gdevelop5:tutorials:platformer:start|Platformer Tutorial, Part 1]] 
 +2. [[gdevelop5:tutorials:platformer:part-2|Platformer Tutorial, Part 2]] 
 +3. [[gdevelop5:tutorials:platformer:part-3|Platformer Tutorial, Part 3]] 
 +4. [[gdevelop5:tutorials:platformer:part-4|Platformer Tutorial, Part 4]] 
 +5. [[gdevelop5:tutorials:platformer:part-5|Platformer Tutorial, Part 5]] 
 +6. [[gdevelop5:tutorials:platformer:part-6|Platformer Tutorial, Part 6]] 
 +7. Platformer Tutorial, Part 7 
 +8. [[gdevelop5:tutorials:platformer:part-8|Platformer Tutorial, Part 8]] 
 +## Step 1Kill the player 
 +When the player collides with an enemy, the player should die. An easy way to "kill" the player is to delete the "Player" object if it collides with an enemy. 
 +To delete the "Player" object if it collides with an enemy:
 1. Create a new event. 1. Create a new event.
-2. Create a **Collision** condition that checks if the "Player" object has collided with the "Checkpoint" object. +2. Add a **Collision** condition that checks if the "Player" object is colliding with the "Slime" object. 
-2. Create a **Value of a scene variable** action that creates a "CheckpointXvariable with a value of `Checkpoint.X()`+3. Add the **Is on floor** condition to the "Player" object. This ensures that the player only dies if they're on the platform (i.e. not jumping). 
-3Create a **Value of a scene variable** action that creates a "CheckpointYvariable with a value of `Checkpoint.Y()`.+4. Add the **Delete an object** action to the event that deletes the "Player" object. 
 +If you preview the game, running into the enemy will kill you. 
 +## Step 2: Kill the enemy 
 +If a player jumps on an enemy, the enemy should die. Similar to the previous step, "death" in this case means deleting the "Slime" object. 
 +To delete the "Slime" object when a player jumps on it: 
 +1. Create a new event. 
 +2. Add a **Collision** condition that checks if the "Playerobject is colliding with the "Slime" object. 
 +3. Add the **Is falling** condition to the "Player" object. This ensures that the enemy only dies if the player is jumping (i.e. not on the platform). 
 +4Add the **Delete an object** action to the event that deletes the "Slimeobject. 
 +If you preview the game, you can jump on the enemy to kill them. 
 +## (OptionalStep 3: Bounce on the enemy's head 
 +In a lot of platforming games, when the player jumps on an enemy, the player bounces on the enemy's head. This is makes killing an enemy feel more fluid. 
 +To make the player bounce on the enemy's head: 
 +1. Add the **Allow again jumping** action to the "Player" object. 
 +2. Add the **Simulate jump key press** action to the "Player" object.
-## Step 3Send the player to the saved coordinates when they die+{{:gdevelop5:tutorials:platformer:07-05-bounce-kill.jpg|}}
-1. Find the event that checks if the "Player" object is colliding with the "Slime" object. +If you preview the game, you'll bounce on the enemy's head when killing them.
-1. Remove the **Delete an object** action from the event. +
-2. Create a **Change the position of an object** action that changes the X and Y coordinates of the "Player" object to `CheckpointX` and `CheckpointY`.+
-## Step 4Set the player's default coordinates+{{:gdevelop5:tutorials:platformer:07-06-killing-enemy-bounce-preview.gif|}}
-## (Optional) Step 5: Fix the positioning of the player+## Next step
 +Read [[gdevelop5:tutorials:platformer:part-8|Platformer Tutorial, Part 8]].