Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Delay of like 1 second in between the infinite loop (can't use sleep() because it pauses the whole thing)

Author
Message
Thugnificent
8
Years of Service
User Offline
Joined: 16th Aug 2016
Location:
Posted: 16th Aug 2016 21:01
I am trying to make a clicker game basics/prototypes. In this i have to add an upgrade which does auto click, for example when purchased, the upgrade will add 5 coins to the total.

So i put it in a Do Loop, the problem is the coins increase way too fast. I want to be able to put a pause or wait 1 second then add 5 coins to the total_coins_variable.

I was able to slow down the do loop(at least for my purposes, slow down the total_coins_variable) by using a float number and add like 0.0015 to the auto clicker value. This did fix the problem of the fast increment of the total_coins_variable but the problem is there is no accurate way to tell how much time has gone by. So if i write in the game that the total_coins_variable will increase by 5 coins every second, this won't be accurate in this case and manually timing will be a pain and not nearly as accurate.

TLR i want to be able to make a do loop execute the code in it, once every second.

I'd appreciate any and all help.

Thugnificent
8
Years of Service
User Offline
Joined: 16th Aug 2016
Location:
Posted: 16th Aug 2016 21:09
Where did my message go?

I typed all that and it's gone now
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Aug 2016 22:46 Edited at: 16th Aug 2016 22:46
As a new user, you are on temporary moderation. Your message is there

You can save the current time with Timer()



and then check the elapsed time...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Thugnificent
8
Years of Service
User Offline
Joined: 16th Aug 2016
Location:
Posted: 17th Aug 2016 11:20
Thank you so much BatVink, i highly appreciate your response.

I have done what you said there is a problem.

The program waits for the do loop for 5 second ( i tested with 5 seconds so i can see the results better), the program does work as intended but after the first loop it races really fast like before.The timer works only at the first iteration. After that it is normal.

I assume we have to reset the timer somehow, how would i go about doing that?

P.S How do i quote someone on these forums lol? Seems like a noobish thing but i cannot for the life of me find the quote the post button.
Thugnificent
8
Years of Service
User Offline
Joined: 16th Aug 2016
Location:
Posted: 17th Aug 2016 11:29
ok how noobish of me, it was simply fixed by adding ResetTimer() into the if statement

Thank you so much again!
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 17th Aug 2016 13:19
Just need to add



into the if-statement


Seems to be a bit of a waste to use ResetTimer() so often

Login to post a reply

Server time is: 2024-11-24 13:15:32
Your offset time is: 2024-11-24 13:15:32