Game Design Game Development Linux Game Development Personal Development

October #1GAM Entry: Candypreneur

October’s One Game a Month entry is Candypreneur, a candy tycoon game inspired by the classic Apple II game Lemonade Stand.

Download Candypreneur for Linux 64-bit (432 kb tar.gz file)

I wish I had dedicated more time to this project. I had surgery and wasn’t able to work on it while I recuperated, and when I was able to spend time on it, I squandered it.

Still, I learned some things, such as that a best practice for representing money in software is by using integer values to represent cents rather than using doubles to represent dollars.

October #1GAM

October #1GAM

I wish I had time to theme it up a bit more. Some candy icons would have helped.

Also, the economics model is too simple. I managed to add random events that can impact the number of prospective customers, which you can sometimes prepare for if you check the reports screen for the upcoming month.

For this project, I had a much more complex simulation in mind. I wanted competitors, suppliers, customer moods, storefronts, candy ingredients, and research & development.

Even when I scaled down, I still didn’t put in things such as the rising cost of advertising or the ability to take out and pay back bank loans.

I’d say this is probably the project I’m least happiest with. I feel like there isn’t enough there, although some last minute additions make it less certain you’ll sell that candy.

2 replies on “October #1GAM Entry: Candypreneur”

Total low-level wannabe programmer question: why do two separate integer variables for dollars and cents work better than one double to include both? Is it better for memory?

Good question, Mike! To clarify, you use a single integer, not two integers, to represent the money in cents. So $20.00 would be represented as 2000 cents in your code.

When you display the money, you do something like the following:

int money(12345);
std::cout < < "$" << money / 100 << "." << money % 100 << std::endl;

The above outputs:


The real reason for not using a double is that floating point calculations end up being approximations and not very precise.

And then there is this StackOverflow question with answers suggesting you would represent not just cents but sub-cents values in your int:

It complicates the calculations whereas using an int keeps things simpler.

Comments are closed.