RPG Tutorial 3



Attached Files

The following files have been attached to this tutorial:



4,036 visits, 8,332 views



This tutorial hasn't been translated.


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.

Open your Maingame_Event and Include Hudbar Events.

Now before we go to manipulate or control Box_Selector, first thing we can add is our player health and control_bar. Open your Player_Event and add this line.

System every tick = Health_bar set spr_Player.Player_Health. Adding this line your player movement’s routine should look like this:

Now you must be thinking how can I test this and see if it works or not? Simple way to test this is RUN it in debugger. Left of your debugger screen click on spr_player. You will see something like this.

See the red box where Arrow is pointing type 25 or whatever you like fewer than 100 and will see the result of your Player_Health instance variables. This is best way to check if you’re variable or any other things in your code. Construct 2 built in debugger is wonderful tool. Always use it and you will get result you want. I always use it to see result of my calculations. Let’s move on.

First insert ARRAY and name it arr_Hudbar.

Set width = 3

Set Height = 3

Set Depth = 1

Now open your Hudbar Events and add this line of code below

First create Global Variable and name it Hudbar_Move and set it 1.

Now let me explain what we are placing in our arr_Hudbar (ARRAY).

On start of layer

arr_Hudbar set value at 0 “Sword”

arr_Hudbar set value at 1 “Knife”

arr_Hudbar set value at 2 “Health”

also add every tick spr_Boxes set Animation to “ID_” & spr_Boxes. Boxes_ID

Now we are moving into heart of spr_Boxes to manipulate with Keyboard. Please check carefully entering these lines of code. One tiny mistake and the end result will be dreadful and horrific.

If you check this lines of code what we are saying when Right Arrow is pressed add 1 to our Global Variable Hudbar_Move. Also if we press Left Arrow we are subtracting 1 from our Hudbar_Move.

Then we are making sure that when right arrow is pressed Hudbar_Move variable not go beyond Hudbar_Move = 4 because we only have three spr_Boxes. Also on next line we are checking if Left Arrow pressed Hudbar_Move should not go under 1 therefore we are setting Hudbar_Move = 1.

Now rest of code should be easy to understand. If you have any trouble understanding the code please contacts me and I will help you. We at Scirra forum are always willing to help anyone.

See you for RPG Part 4 where we will introduce enemy and more until then take care.

God Bless

Lord Shiva


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