Anyone can help me with a function?
I try create function to buy buildings in my prototype game.
I have a global variable called GOLD, then I have buildings, each have a VarCoast variable ...
Building1 - VarCoast = 1000
Building2 - VarCoast = 500
Building3 - VarCoast = 2000
I want to create a function to subtract gold from my GOLD global variable.
I try this:
- Mouse On left button Clicked on Bulding 1 >> Function Call "Buy"(VarCoast)
- GOLD => param(Varcoast) >> Subtract (VarCoast) from GOLD
BUT... How I get VarCoast to subtract to my global variablo GOLD?
I make this easily without make function. But I have to repeat the code for each building. I think a function let the code cleaner.
Got the point?