Lootable-Money System

1
• 9 favourites

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

2,781 visits, 4,133 views

Translations

This tutorial hasn't been translated.

Now for the juicy bits! When the player approaches coins in real life? Well, he takes the coins and puts them in his wallet. That's what we want to achieve, to make the coins disappear and re-appear into his "wallet", or the Global Variable. Here is what you want to insert into you event sheet:

Here is what's going on:

1) The condition 'Player on collision with Coins' checks if the Player walks up to the coins and 'touches' them.

2) The 'Coins destroy' event is pretty self-explanatory. It destroys the coins. This is VERY important. If the coins don't disappear, the Player could keep on going back and forth and collecting a LOT of cash. We just want him to collect whats there. You could add some kind of animation of picking up the coins or a sound or rattling coins, but I'll keep it simple.

3) The next event is very interesting and VERY important. The 'System add int(random(10)+10) to Cash' event actually gives you the cash. I'll have to break it down a bit first.

The 'random' bit is quite interesting. The game picks a completely random numbers between 0 and 10 and pops it in. If you want to make it more random, then change the number in the brackets. The +10 just adds ten so you are sure of getting a number more then ten cash.

But, the randomiser has it's flaws. If you make a random number it will make a whole bunch of decimals to make it really random. So the 'int' part, or the integer, take the final answer and gets rid of the decimal. If your a mathematician you should know about this.

Of course you could end it there but there is one thing that would stop you. It's too easy. You have the coins there, just sitting there, forever. So, the coins should slowly disappear. That's why the coins have the 'fade' behavior and the Destroy after fade out setting. Here is the last event:

Here what happens in this event:

1) The condition 'Coins is on-screen' tells the game to wait until the coins actually appear, not just start hilly-billy.

2) The first event 'System Wait 5.0 seconds' says to wait 5 seconds before going on with the next event. This gives a bit of time for the Player to get the coins. Of course, you could make this time as long or as short as you want.

3) The last event 'Coins Fade: Start Fade' Tells the Coins to start fading away. The time I set is 1 second, and after that the coins disappear for real. Also remember to go to the Fade's settings to set 'Active on start' to NO.

And that's it! Here is what it should look like if you've done:

It should work okay, the coins should disappear after time and the coins give you 10 to 20 cash, which is displayed in the text. Of course, you could intertwine this into your own game. A dungeon game is perfect for this style. Two ways to use it is to have bunches of these in the final room, or have certain enemies drop small stacks. Feel free to mess around with the numbers and stuff. But that is it, there is and Example capx available, and Thank you for reading!

.CAPX