Platform game Start to Finish

3

Index

Attached Files

The following files have been attached to this tutorial:

.capx

demo-game.capx

Download now 5.33 MB

Stats

8,884 visits, 18,528 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 22 May, 2018. Last updated 19 Feb, 2019

That’s our player Routine (Function) is done;

First, create a layer, and call this layer Enemy, and place it under Player layer;

Now we require some kind of object that can harm our Player, create a sprite, and call it Spike, also create Instance Variable for Spike, Spikes_ID as 1 and 2;

Place it where you think best to trap Player, on my game tutorial I have placed it on the map where Dark Red rectangle is;

Our goal is if a player touches spike, he surely dies. But, if Player trigger some kind of switch or another kind of triggering object, then Spike can be destroyed or deactivated. So I have created Gem to pick up by a player and render Spike useless but the first player collision with the spike;

That’s all we need because soon as you set isAlive to zero Game ends with the message saying Game Over! As I said we will cover this messages in HUD layer, therefore don’t worry about this at the moment, please.

To deactivate our Spike create the sprite, and name it spr_Switch, create Instance Variable, and name it Switch_ID =1 Switch_ID= 2, also set Collision to disable in property, and place it as shown with the red square;

Red Switch_ID = 1

Green Switch_ID = 2

Enter this code;

We checking, is played in the collision with spr_Switch, if yes then compare spike ID and Switch ID if both of this condition is met (happened) then switch is destroyed or else it will not be destroyed, in that case, player touches switch it will set or isAlive to Zero.

Create sprite and name it spr_SwitchTR, and create Instance Variable, SwitchTR_ID = 1, SwitchTR_ID = 2. Place it as I have where Rectangle is;

Create sprite, and name it spr_Diamondgem, create Instance Variable Diamondgem_ID = 1, Diamondgem_ID =2; and place it as shown;

Enter code;

If you check this condition there is no difference between Switch condition and this code, the only thing we changed is spr_Diamondgem and spr_SwitchTR.

Create sprite, and name it spr_GoldBar, place it anywhere you like; also create Global variable Goldbar = 0;

Here we are asking Construct 2 check collision between player and Goldbar, to choose scores and add 1 to our Goldbar Variable. When the player wins the game we can say player collected so many Goldbar and scores too.

Create sprite, and name it Key, create Instance variable and name it Key_ID = 1, Key_ID = 2, add fade behaviour and set the property to not Active at the start, place your key where Red square boxes are.

Create sprite, and name it Door, create Instance variable name it Door_ID = 1, Door_ID = make these door solid in behaviour so the player cannot enter without Key, place your Door where green square boxes are.

Enter code for key and door

Now time to add enemy, for this I have Snakes 1 Red, and 1 Blue.

Create sprite, and name it Snake_Enemy, create 2 Instance Variable, Snake_ID = 1, SN_Health = 5, set behaviour Fade, and set fade Active to NO, also set as solid 2 because we don’t the player to jump over the snake, do we?

For Snake create 2 Animation, and name Red, and Blue. To make snake animation copy of Red Snake then click on the middle frame to select it. Now use your Rectangle select Tool and select middle frame Snake. Move 1 pixel down the selected snake, and save it. Do the same for Blue, also set Image point 0 to Bottom and image point 1 to by snake mouth. Set Speed rate to 3, and set loop to Yes. Place your Snake as I have.

  • 0 Comments

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