I am currently developing a game on my calculator but the way that the game calculates time isn't accurate all of the time. It adds ten to the current system time that I retrieve by using chktimer to make a countdown for the user to push the enter button as fast as they can.
It then gives the user between 10-9 seconds instead of an actual 10 seconds of time, which really bothers me because the high scores won't be accurate if one user might get 9.9 seconds while the other one gets 9.1. Is it possible for the calculator to give the user exactly 10 seconds?
Thanks in advance.
The RTC clock on the 84+ will only report seconds, not fractions of seconds.
You could first wait until the "Seconds" part of the time changes, and count 10 seconds from then, that would introduce up to a second of delay but it should be fairly accurate.
If you can use ASM subroutines, you could try using the crystal timer.
How do you even use the clock at all? I tried to use it once on my friend's 84 Plus, but I couldn't figure out any of it.
If it doesn't report fractions of seconds, then, yes, waiting for a Seconds change is a good idea.
Compynerd255 wrote:
How do you even use the clock at all? I tried to use it once on my friend's 84 Plus, but I couldn't figure out any of it.
The command getTime can be used to get a three-element list of current hour, minute and second. There's also getDate for dates, and a few functions that return strings.
As harold suggested, you can wait in a tight loop for the seconds to change, then start the game there. Kpa, you should be sure to start a Your Projects topic about this!
I will most likely start a thread of my game in the Your Projects section soon, but I still don't really get this "tight loop". Would I run loop that continuously checks the time and once the seconds changes it would proceed with the program?
That's exactly it. By "tight", they mean: a loop with very little code except for the condition you are checking. For example, here is some code that will wait for the time to change, and then continue with the loop. It uses K as the clock variable that you use CheckTimer() with.
Code: StartTimer->K
Repeat Ans>2
CheckTimer(K
End
StartTimer->K
// Rest of code here
CheckTimer(K // Display the seconds it took
I choose the seconds to be 2 because I think it will be more precise. With 1, it might mess up, if I recall correctly. Though, that is only my observation. Feel free to change it, s'il vous plaƮt
Thank you for your code. I added it to my program and the countdown timer gives everyone an equal and fair time limit now.
kpa4941 wrote:
Thank you for your code. I added it to my program and the countdown timer gives everyone an equal and fair time limit now.
Excellent, that's great to hear.
Another success for Cemetech's TI-BASIC coders.
As a small note, not that I discourage using the clock completely when it's necessary, but whenever possible, I recommend creating your own clock, even if it's not accurate, so that your game will run on the TI-83 Plus and TI-83 Plus Silver Edition calculators, which still got a large userbase. This is what I did in Illusiat 7, back in 2002 (although back then this was not the reason why, as the TI-84 Plus did not even exist, back then)
Indeed, but the problem with the non-crystal calculators is that their CPU speed changes with the power level of the batteries.

You can more or less approximate it with some careful loop counting, though, so that's a good suggestion.