Making a cool map screen Part II + Storing Level collectables
Author: | Phredreeke
|
Submitted: | 3rd May, 2005
|
Views: | 5227
| Rated: |
|
|
On the first part of my map screen tutorial, I explained how to make a map screen with level names. (if I weren't clear enough in the last one, it's for making a map to select levels on) In this part, I'll go a bit further, explaining how to animate the markers when held over by the mouse, and how to display level completion status. Also I'll go into a way to storing level collectables. I assume for this tutorial you already have made animations for your level markers.
Make a new condition, a negated mouse pointer is over Group.0, add the action Force animation frame to 0 (other frame numbers can be used as well) on Group.0
Then on the condition we added last time, mouse pointer is over Group.0, add Restore animation frame to Group.0
Now, when you hold the mouse over a level marker, it will animate, and when you move it away, it will stop.
Now we will add level completion status to the text after the level name. Go back to the condition, mouse pointer is over Group.0, and change the alternable string. After
paragraph$( "String", Alterable Value A( "Group.0" ) )
add
+ " " + str$(Global Value(Alterable Value A( "Group.0" )) )
This assumes level completion status (amount of coins collected for example to be saved at the global value of the same number as the paragraph with level name. However, this would limit the amount of levels to 16, and you'd lose a global value for each level. While this may be enough for your game, it's still not very practical, and it would limit the collection of items to either: 1. get each item in order or 2. get all items over again every time you play the level.
You can use a 1000 global values object, but it still limits the item collection. That's why I'm adding a sub-tutorial explaing the way I solved it in Scurvy Sanchez 3:
Dedicate a global value for each level (I only have 5 levels with collectable coins, so it's no problem, otherwise I could have used the above mentioned extension)
Determine how many collectable items you want. Calculate 2^x with x being the amount of items. For this example, lets assume you want you want ten items, 2^10 is 1024. Also assume Global Value A is used for storing the value of the current level's collectibles. First, add this condition, Global Value A < 1024, with the action setting Global Value A to 1024.
This is to ease checking the existance of a single binary value. You have to repeat this for every collectable. Add a compare two general values condition, with the following two values
Mid$( Bin$( Global Value A ), 3, 1 )
This means the game will extract the fourth (0 is the first) single digit from the binary string generated off Global Value A. All binary strings begin with 0b and the highest bit will be 1024 because of the previous event we made. The next value is a bit simpler.
"1"
The reason why it's between quotes is because it's a string and not a value, because of the use of Mid$. The action for this condition will be destroying the collected object.
For the same object, when "collected", add 512 to Global Value A and destroy it. You can do several variants of this, including using multiple binary digits, or using decimals. But that will make the work on the map screen harder.
Now, back to the map screen. Instead of changing the alterable string to this:
paragraph$( "String", Alterable Value A( "Group.0" ) ) + " " + str$(Global Value(Alterable Value A( "Group.0" )) )
Lets change it to this
paragraph$( "String", Alterable Value A( "Group.0" ) ) + " " + str$(Alterable Value B("Group.0"))
Since we don't have any Alterable Value B yet, we have to create it, using another event. Add the following condition, Alterable Value C < 10, and actions to add this to value B
Val( Mid$( Bin$( Global Value( Alterable Value A( "Group.0" ) + 5 ) ), 3 + Alterable Value C( "Group.0" ), 1 ) )
And a second action to add 1 to Alterable Value C.
Now, when holding the mouse over the level marker, you will see the amount of collectables gotten in the level after the level name. However, you might want to use something other than the digit. Try changing the alterable string to:
paragraph$( "String", Alterable Value A( "Group.0" ) ) + "
" + Left$( "**********", Alterable Value B( "Group.0" ) )
(you create the line breaks by pressing ctrl and enter) Now, when holding the mouse over the level marker, you will see a star for each item collected below the level name. In case the amount of collectables are the same for every level, you could change it to show the progress in percent.
paragraph$( "String", Alterable Value A( "Group.0" ) ) + " " + str$( (Alterable Value B("Group.0")*100)/10 ) + "%"
|
|
PhredreekeDon't listen to this idiot Registered 03/08/2002
Points 4504
|