GML Clicker/Idle Games

Dragula5892

Member
I feel dumb for asking this, but how to i make a proper math table for clicker games? like when you buys items they very slowly get more expensive, i have a kinda example on the steam workshop, but it's not as good as i'd like it to be, it doesn't feel proper
 

NightFrost

Member
Incremental costs in clickers are based on the formula of: next unit cost = base price * N ^ current unit count where the optimal range for N is generally agreed to be between 1.07 and 1.15. In my clicker, I used 1.11 as the value. So, if base price is 100, second unit will cost 100 * 1.11 ^ 1 = 111, third costs 100 * 1.11 ^ 2 = 123, and so on.

Your bigger problem is the score. Clickers deal in massive-huge numbers, and GM can't handle numbers beyond certain limit - little over 2 billion I seem to recall. You must create a system that handles large numbers. I chose to use array, and could easily handle the longest number that could fit into the UI (fourty zeroes or so). I had to build special functions that would add, substract and multiply numbers that are represented as arrays. For the 1.11 ^ X results I simply cheated and made a long precalculated result list and stored them into an array. So when I needed to know what was 100 * 1.11^450, The answer would be Price = scr_array_multiply(global.UnitBasePrice[SelectedUnit], global.PreCalculated[450]);
 

Dragula5892

Member
Incremental costs in clickers are based on the formula of: next unit cost = base price * N ^ current unit count where the optimal range for N is generally agreed to be between 1.07 and 1.15. In my clicker, I used 1.11 as the value. So, if base price is 100, second unit will cost 100 * 1.11 ^ 1 = 111, third costs 100 * 1.11 ^ 2 = 123, and so on.

Your bigger problem is the score. Clickers deal in massive-huge numbers, and GM can't handle numbers beyond certain limit - little over 2 billion I seem to recall. You must create a system that handles large numbers. I chose to use array, and could easily handle the longest number that could fit into the UI (fourty zeroes or so). I had to build special functions that would add, substract and multiply numbers that are represented as arrays. For the 1.11 ^ X results I simply cheated and made a long precalculated result list and stored them into an array. So when I needed to know what was 100 * 1.11^450, The answer would be Price = scr_array_multiply(global.UnitBasePrice[SelectedUnit], global.PreCalculated[450]);
alright, you're sure there isn't a simpler way to do this?
 

NightFrost

Member
You mean large numbers? If you want those, I'm afraid you need some way to handle them that doesn't involve just using variables straight. One method could be to drop off least significant digits when the score gets large enough. First step being dropping off the three least significant digits and appending a "k" at the end of the number, and going upwards from there. That also means not adding to score anything that is less than a 1k increment, and rounding anything larger to 1k precision. I didn't like that idea so I wrote in the array method to display the complete number.
 
V

Vortex

Guest
A little late but is it possible you could describe in more detail how to make the array?
 

Mr Magnus

Viking King
Depends at what rate you want things to get more expensive.

If you want things to get more expensive by a fixed number:

GML:
Price = base_price + units_bought * value_to_increase_price_by
If you want the gap to get bigger as time goes on

GML:
Price = base_price * power(units_bought, some_constant)
if you want it to get slowly more expensive at first and then become pretty much impossibly expensive


GML:
Price = base_price * power(some_constant, units_bought)


you can then adjust all of these parameters simply by having for instance an array that you fetch things from, like

Code:
price_constants = [
    100,
    105,
    110,
    125,
    150,
    200,
    260,
    340,
    500,
    1000,
    1200,
    1500,
    2000,
    4000,
    6000,
    100000
];

price = base_price + price_constants[min(15,round(units_bought / 50))] * units_bought;
 
V

Vortex

Guest
no no, the array that allows you to work with numbers higher than the integer limit
 
Top