G
G
GingerSibe2022-04-11 14:28:56
C++ / C#
GingerSibe, 2022-04-11 14:28:56

How to make the clicker work in the background?

Hello, for many clickers, when you upgrade automatic currency generation, close the application and then go in, then a window pops up like "You have accumulated 50,000 currencies while you were away", please tell me how to do this so that while my application is closed, then currency would accumulate further>?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Boronnikov, 2022-04-12
@GingerSibe

In full-fledged clickers and other games where the gameplay is used in a "non-working" state - either the mechanics work on the server (which is rarely done, only in cases of possible influence of other players from the outside), or they carry out an accelerated simulation.
For example, there is some building that accumulates gold over time in a time according to the formula
сurrency(t) = t*currencyPerSecond
where t is time, and currencyPerSecond is the amount of currency accrued in seconds.
As a result, the player sits and plays, receives currencyPerSecond every second . And here we have to save somewhere the moment at which we last received this currency. For example, at 11:00 the player received currencyPerSecond and now he has 10000 gold. We recorded this and saved it to a save file, some json or something like that.
The player closed the game and opened it in half an hour, at 11:30 .
We went to see when the player last received the currency - at 11:00 , and now it's 11:30 - so he was absent for 30 minutes and we have to generate him

30*60*currencyPerSecond (30 минут * 60 секунд * на величину получаемого золота в секунду)

And then, if more than 0, then we show the player a window that "You have accumulated 30*60*currencyPerSecond of currency. And in total you have 10000 + 30*60*currencyPerSecond ".
currencyPerSecond - can itself be a formula such as number of buildings built * 2 or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question