Need help with currency system

How do you make a currency system in a rpg like game. Like you buy you some food from your overall currency.
Food is 30
Your currency is 100
30-100 *Then displays your currency left* which will be 70
I used arrays need your help please.
You'll have to be more specific... Using arrays says absolutely nothing about your problem.
Currency is maybe the wrong term. Do you mean "money" or "balance"?
30 - 100 is -70, not 70 (its confusing)

I assume you are programming a console based text rpg?

Nobody wants to guess what your problem is.
well say your currency is in dollars (just an example)

1
2
3
4
5
6
7
8
9

int dollars = 100; //this will represent how much money you currently have

if  (<player buys food>) {

dollars = dollars - 30;

}


hope this helps!
Last edited on
Topic archived. No new replies allowed.