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.

Dark GDK / Timer Trouble

Author
Message
Lancelot Reefs
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location:
Posted: 24th Oct 2008 06:52
I want to make a sprite rotate 90 degrees every second, here's the code:



I dont see what the problem is though.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 24th Oct 2008 15:18
You are looking for an exact match on the milliseconds - that's not very likely to happen.

Instead, try something like this:


That will trigger the rotation every time the timer refers to a different second - it's not a great method, but it's the best I can come up with with the description you've given.

SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 24th Oct 2008 15:28
What I found to be much easier, is instead of trying to count from 1 to 0, use Clock() in the windows Time header.

Measure when 1000ms has passed. Im not to sure on how dbTime() works but I always end up using clock() after having much trouble with timer based jump using dbTime().

Make sure you include "Time.h" if you decide to use Clock().

www.Helios-Online.net
Lancelot Reefs
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location:
Posted: 25th Oct 2008 04:58
OK guys, I found a way to make it work using clock(). Here is the code in case you're interested.



It's inefficient I know, but it works.
Lancelot Reefs
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location:
Posted: 26th Oct 2008 08:21
Okay guys I still have a tiny problem, and I posted the whole code so you can run it. The sprite rotates every 100 milliseconds however, sometimes it waits longer than 100 millisecs to rotate (i.e. 200 millis). What seems to be the problem?
The last if statements in the while loop is what does the calculation.

Attachments

Login to view attachments
Lancelot Reefs
16
Years of Service
User Offline
Joined: 22nd Sep 2008
Location:
Posted: 26th Oct 2008 08:27
Here is the second bitmap!
Ohh and the green dot was used for another test so it can be taken out!

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 05:11:29
Your offset time is: 2024-11-25 05:11:29