Zelda Inventory (the easy way)

3

Stats

6,314 visits, 9,580 views

Tools

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 8 Oct, 2013. Last updated 19 Feb, 2019

Hi all,

Hopefully this tutorial will help you in creating an inventory in the style of the zelda games, this will use the plugin "Dictionary". This is not the most efficient way to do it, but it will hopefully give beginners an idea and then can improve on it.

1. Create a new layout and call it "Inventory" then add the Dictionary object to your project.

Lets say you have 4 weapons and some arrows: sword,boomerang,bowarrow,mallet and arrows. The dictionary is what is used throughout the game to track what weapons and items you have and how many.

2. Input these items into the "KEY" slots of the dictionary with a "VALUE" which will be the amount, a value of 0 will mean they have not been obtained yet. Example:

(KEY) (VALUE)

sword = 1

boomerang = 1

bowarrow = 1

mallet = 1

arrows = 10

3. This "dictionary "will be updated as you progress your game but for now all items have at least 1 available at the start for the purpose of this tutorial

4. Create a sprite and call it "weaponsicon" and put in each frame the weapon icon for Example:

frame 0 = sword image

frame 1= boomerang image

frame 2= mallet image

frame 3= bowarrow image

frame 4= arrow image

frame 5= background inventory image(for weapon not acquired)

5. Lay the "weaponsicon" sprite objects out in an equal distance apart from each other (lets say 32pixels) in your layout.

5a. Create a instance variable called "weaponanimationnumber" for the "weaponsicon" object and set the instance variable on each instance on the object to 0,1,2,3,4,5(representing each of the weapons frame number)

5b. In the object properties set the frame number of all the "weaponsicon" objects to 5(which should be the inventory background image).

6. Create a cursor for selecting the weapons and set it's position equal to the 1st "weaponsicon" in this case its the "sword"

7. Have the cursor move left,right,up and down to the same value the weapons are distanced (in this case 32 pixels), this way the cursor will perfectly overlap the weapons. Example:

if left arrow key pressed then set cursor x postion to cursor x postion - 32

if right arrow key pressed then set cursor x postion to cursor x postion + 32

if up arrow key pressed then set cursor y postion to cursor y postion - 32

if down arrow key pressed then set cursor y postion to cursor y postion + 32

8. You then need to add extra code to "wrap" the cursor if when needed, as if your last weapon is at position x 400 and you press right it will move to 432, were theres no weapon. The following code is used to move the cursor back to the 1st column and vice-versa.

If cursor x position > 432 then set cursor x position at 272( first weapon location).

If cursor x position <272 then set cursor x position at 400( last weapon location).

Do this for the y positions too.

9. Set up a global variable (text type) called "equiptweapon" and set default value as "none". The value will change depending on the weapon selected.

10. Now we want the weapons to be hidden if they are not acquired or have been used up (such as arrows), the logic for this is as follows:

If sword value = 1(is in inventory) and the "weaponsicon" instance of that objects "weaponanimationnumber" =0 (which is the sword) then set the "animationframenumber" of that object to the same value.

NOTE: the not acquired value of the Arrows is set to -1), this is so the Arrows will display in the inventory if you have acquired them but have none left(value=0)

11. Now for the actual selection of the weapons/items. Check if cursor is over a given "weaponicon" instance and set the global value "equiptweapon" to that weapon.

12. As an additional option i've duplicated the "weaponsicon" renamed it "equiptedweapon" to show which weapon it currently selected.

video of the inventory working

http://www.scirra.com/forum/zelda-a-heros-journey_topic83119.html

  • 0 Comments

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