Okay... So let's plan it a little. You create an integer variable called stress.
AM will automatically save and load it for you.
Then you change it using simple maths
- Code: Select all
stress=stress=+i
Where "i" is replaced by the number you want to add to the player's stress with this action. You can also decrease the variable's value using the same method replacing "+" with "-".
Now the difficult part.
You can scale the player's stress from 1 to 100 or whatever you like. Well let's use 1 to 100 for this tutorial...
It's possible to simply display the score like with time (there's already a tutorial for that one). All you 've got to do is create a blank frame, add a text with right click and place it where you want the stress to be displayed in every frame. Then go to every frame of your game you want the stress to be displayed and merge them with the blank frame. Now go to project properties, under advanced select "Execute some VBScript code every time that a frame is loaded" and type this code:
- Code: Select all
i=Action.GetMergedTextIndex
Text(i).Caption="Stress:"+" "+cStr(stress)
Of course you will have to check for the hard limits every time you decrease/increase the stress using Ifs. For example
- Code: Select all
If 1<=stress and stress<=100 then
stress=stress+1
Else If stress>100
Action.GotoFrame "Overstressed"//remember to replace the frame or the whole code to fit your needs
End If
End If
Now, there is another way: The status bar. You can create a stress bar by adding a bitmap in a hotspot's appearance in the merged Stress Frame (note that the bitmap should be selected to stretch to fit the hotspot)...
Then using vbs you will be able to simply decrease/increase it by adding some code in the "Execute some VBScript code every time that a frame is loaded" like in the previous method. Type:
- Code: Select all
hotspot(Action.GetMergedHotspotIndex).move x*15,y*15,w*15,h*15
where x,y are the coordinates of the hotspot and w,h its width and height.
Well in case you can't get it yet, you must select a permanent set of x,y and h and alter the w depending on the variable's value (that's for an horizontal bar. If you create a vertical one you will need to decrease the value of y to make the bar go up).
Now if you just type the code I wrote above you won't have any results. You will need to integrate the stress variable and multiply it with w, then make some other mathematical procedures to have a functional bar. I will try to make a sample, but since you 've worked on C, I think you will find your way out (and if you do, please post it here for me to see it
).
Note that if you alter the stress in a frame and you use the bar method, you will have either to reload the frame by going to it again
- Code: Select all
Action.GotoFrame "Action.GetCurrentFrameName"
or to execute the code that is executed every time a frame is loaded from the hotspot or dialogue that changes the stress variable
Anyway, if there's anything you don't get, feel free to ask.
To Moderator Team: please, transfer this one to tutorials, could be useful.