I am trying to use money in my game.
I have read the tutorial on variables and now understand how to add and subtract from a variable that I could call "money" or "cash".
What I now need is a way to show how much money I have in the game rather than the player have to try remembering.
I want the simplest way of doing this either in the gui or just as text on the screen.
Thanks.
Hi
There are a number of ways.. You could have it as a label on a gui... In events pane for that label: Change text to @SCORE@ .. you could have it as £ @SCORE@ for example.
There is also a Set maximum score in the General Tab of the game if you need it.
To award the player money use:
GiveScore (0); // score to add or subtract
SetGlobalInt (0, 0); // Index,value
The total would be updated and shown on the gui via the label.
Check these out in the manual for more info..
There are other ways others may explain to you if you are using a variable etc
barefoot
If you don't want to use SCORE but some custom variable (e.g cash), just create a label and call this whenever the amount is changing (or just put it somewhere in the repeatedly execute):
Labelname.Text = String.Format("%d", cash);
Thanks barefoot that's exactly what I needed, so can I use the variable commands += and -= to raise and lower the gamer score?
Hi
Just put the amount you want to add/subtract at whatever point you want it to be (eg gaining an inventory item, clicking something... whatever...)
GiveScore (1) adds 1
GiveScore (5) adds 5
GiveScore (-1) subtracts 1 etc etc
Eg
Display("You have sold your motor bike");
GiveScore (1000) ;
The label will be updated if you have it done correctly (using @SCORE@..
barefoot