December 06, 2019, 09:30:19 pm

News:

Juju thinks he's so clever by putting funny stuff here


The shoutbox is currently out of service. Join us on Discord instead.
You can help CodeWalrus stay online by donating here.

Timer in Nspire Lua

Started by semiprocoder, December 24, 2015, 04:35:57 pm

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

semiprocoder

December 24, 2015, 04:35:57 pm Last Edit: December 27, 2015, 09:56:42 pm by semiprocoder
Recently, for cookie clicker and my idea for the contest(which I am still not sure about(it is basically going to be a don't touch the spikes remake if I decide on it)), I have been using something along these lines(this is for the game I am working on currently, and vel, coords, and accel are vectors):
edit: nvm, can't release code for contest
and similarly for cookie clicker:

  self.output*self.amt*(millis()-prevTime)/1000


I have for a while known that my cookie clicker game never gives the full income per second. I didn't think it was too much, as, even at optimal 30 fps, it would have an innacuracy of (3.3-3)/3.3, which is about only 10%, which, while being annoying, isn't too ridiculous.

However, over the time I have played my cookie clicker, I have noticed that the actual error is bigger than just 10%. Furthermore, a few minutes ago I looked at the documentation again to try to find something better than milliseconds, and noticed that even timer.getMilliSecCounter() doesn't even return the milliseconds with accuracy to a millisecond. It returns only with an accuracy of 0.02, which makes more sense with the numbers I get with cookie clicker.

Thus, the question I ask is this:
1. Are there any better ways to get time in lua?
2. What are some alternatives to using time to calculate the multiplier for accel/velocity?[/code]
My cemetech username is awesommee333.

Powered by EzPortal