Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

liquidAir

Need help with timers - preferably SDL

This topic is 5826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Helo there! I''m using the SDL library timer functions. My problem is, I have basically no idea on how to program with timers. What I want to accomplish is - display something on the screen - wait for some seconds - clear the screen - display another thing and repeat process till I get to the last item to display Can I get code on how to do this? Or where can I get timer tutorials?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Time is relative.

Share this post


Link to post
Share on other sites
'cept the only problem with that is that it freezes the entire application which, depending on the situation, wouldn't be of much help. I just ditched SDL's timers and programmed my own timer manager class anyways. The only thing SDL has over mine is callbacks as opposed to polling. I'll be fixing that soon tho.

_________________________________________________________________

Drew Sikora
A.K.A. Gaiiden

ICQ #: 70449988
AOLIM: DarkPylat

Blade Edge Software
Staff Member, GDNet
Public Relations, Game Institute

3-time Contributing author, Game Design Methods , Charles River Media
Online column - Design Corner at Pixelate

Unnoficial IGDA chat! [polaris.starchat.net -> #igda]
NJ IGDA Chapter - NJ developers unite!! [Chapter Home | Chapter Forum]

"Real programmers don't work from 9 to 5. If any real programmers are around at 9am it's because they were up all night."
-Anon.

"It's not the size of the source that matters, it's how you use it"
- Self

Share this post


Link to post
Share on other sites
timeGetTime(), anyone? Always been a good friend of mine...
{EDIT: (added)} Okie... took a look at said sdl docs, out of sheer curiosity. The function Uint32 SDL_GetTicks(void); looks DARN tasty- since it returns the "uptime" of something (in this case the time since SDL was initilized), you would just have to calculate at the start of each program(/game) loop how many milliseconds have elapsed since the last time the program looped- JUST like using timeGetTime!!! Wheeeee!!!! thusly...

... at the beginning ...
Uint32 uiTickTime = SDL_GetTicks();
Uint32 uiLastTime = SDL_GetTicks();
... at the start of your loop ...
uiTickTime = SDL_GetTicks() - uiLastTime; // "Get the number of milliseconds since the SDL library initialization."
uiLastTime = SDL_GetTicks();

For the sake of arguement, say the values are initilized 100ms after SDL initilization. If the loop begins 140ms after, then TickTime will be 40ms, and LastTime will be then set to 140ms. If it takes until 160ms later, then TickTime is 20ms, and LastTime is again set to the older time. Hmm... I'm very tired atm, but that looks *KINDA* right... (must... sleep...)

[edited by - Tok on December 5, 2002 12:08:21 PM]
[edited by - Tok on December 5, 2002 12:13:37 PM]
Hmmm... nah, forget it. Been up all night, and not making much sense now.

[edited by - Tok on December 5, 2002 12:15:42 PM]

Share this post


Link to post
Share on other sites
timeGetTime is not platform independent. Most windows OSes don''t like it.

Check out the Portable Game libraries at http://plib.sourceforge.net/index.html for a great clock class. I was able to get up and running real quick, just using the Utility Library''s ulClock class.

-crombie

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!