Jump to content

How to add timer in SDL?

- - - - -

  • Please log in to reply
3 replies to this topic

#1
even821

even821

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
i wanna add a timer to my ping pong game, so that every 30 seconds the players paddle will be halved in sized (to add more of a challange to the game). is there any way to do this? i allready know how to divide the paddle by two, so i only need to add the timer.

#2
Flying Dutchman

Flying Dutchman

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 889 posts
  • Location:::1
Timing and advanced timers SDL tutorials. Lazy Foo' of course. :)
A conclusion is where you got tired of thinking.
#define class struct    // All is public.

#3
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 552 posts
  • Location:/etc/passwd
Just use int startTicks = SDL_GetTicks() and then doy our stuff before using endTicks = SDL_GetTicks() - startTicks;
endTicks will have the milliseconds between when you set startTicks and when you set endTicks.
^The tutorial above has it all^
I recommend you read all of Lazy's tutorials (apart from OpenGL and stuff).
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#4
even821

even821

    Learning Programmer

  • Members
  • PipPipPip
  • 70 posts
kinda like how you would limit the FPS in your game?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users