itch.io is community of indie game creators and players

Devlogs

QoL Update Multi Buy Button

Feed the bunny
A browser game made in HTML5

Maybe not the most important feature for a game.
But I like "Multi Buy Buttons" and it was one of my open tasks for "Feed the Bunny".

My solution

Cycle through the different options and set the button text:

Function for calculation of the upgrade costs for a 'bulk' upgrade

I use a struct so I can return the values for the costs and the number of levels:

Calculate the current Basecost:

Finding out how many levels are needed to reach the multi buy goal:

a) for a set number of upgrade levels:

b) for fill level to 10 or 100

c) for MAX levels

Now that I know the number of upgrade levels I can calculate the sum of the upgrade costs for a 'bulk' upgrade:

Return the values (remember I used a struct to return 2 values):

And that's it. :-)

I look forward to comments on how other developers have solved this and hope I can help one or the other beginner with my solution.

Thank you for reading so far and apologizes for my English. I hope you understand anyway.

Leave a comment