pygame / docs / ref / time.html

Full commit

<title>time - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>

<table cellspacing=3 width=100%><tr><td bgcolor=#00000>
<table width=100%><tr><td bgcolor=c2fc20 align=center>
    <a href=>
    <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br>
</td><td bgcolor=6aee28 align=center valign=top width=100%>

	<a href=>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
<a href=display.html>Display</a>&nbsp;||&nbsp;
<a href=draw.html>Draw</a>&nbsp;||&nbsp;
<a href=event.html>Event</a>&nbsp;||&nbsp;
<a href=font.html>Font</a>&nbsp;||&nbsp;
<a href=image.html>Image</a>&nbsp;||&nbsp;
<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
<a href=key.html>Key</a>&nbsp;||&nbsp;
<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
<a href=movie.html>Movie</a>&nbsp;||&nbsp;
<a href=music.html>Music</a>&nbsp;||&nbsp;
<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
<a href=rect.html>Rect</a>&nbsp;||&nbsp;
<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
<a href=surface.html>Surface</a>&nbsp;||&nbsp;
<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
<a href=time.html>Time</a>&nbsp;||&nbsp;
<a href=transform.html>Transform</a>


<a name="pygame.time">
  <i>pygame module for monitoring time</i><br>
  <tr><td><a href="time.html#pygame.time.get_ticks">pygame.time.get_ticks</a></td><td>get the time in milliseconds</td></tr>
  <tr><td><a href="time.html#pygame.time.wait">pygame.time.wait</a></td><td>pause the program for an amount of time</td></tr>
  <tr><td><a href="time.html#pygame.time.delay">pygame.time.delay</a></td><td>pause the program for an amount of time</td></tr>
  <tr><td><a href="time.html#pygame.time.set_timer">pygame.time.set_timer</a></td><td>repeatedly create an event on the event queue</td></tr>
  <tr><td><a href="time.html#pygame.time.Clock">pygame.time.Clock</a></td><td>create an object to help track time</td></tr>
<p>Times in pygame are represented in milliseconds (1/1000 seconds). Most platforms have a limited time resolution of around 10 milliseconds. </p>

<a name="pygame.time.get_ticks">
  <i>get the time in milliseconds</i><br>
  <tt>pygame.time.get_ticks(): return milliseconds</tt><br>
<p>Return the number of millisconds since <tt><a href="pygame.html#pygame.init">pygame.init</a></tt> was called. Before pygame is initialized this will always be 0. </p>

<a name="pygame.time.wait">
  <i>pause the program for an amount of time</i><br>
  <tt>pygame.time.wait(milliseconds): return time</tt><br>
<p>Will pause for a given number of milliseconds. This function sleeps the process to share the processor with other programs. <tt>A</tt> program that waits for even a few milliseconds will consume very little processor time. It is slightly less accurate than the <tt><a href="time.html#pygame.time.delay">pygame.time.delay</a></tt> function. </p>
<p>This returns the actual number of milliseconds used. </p>

<a name="pygame.time.delay">
  <i>pause the program for an amount of time</i><br>
  <tt>pygame.time.delay(milliseconds): return time</tt><br>
<p>Will pause for a given number of milliseconds. This function will use the processor (rather than sleeping) in order to make the delay more accurate than <tt><a href="time.html#pygame.time.wait">pygame.time.wait</a></tt>. </p>
<p>This returns the actual number of milliseconds used. </p>

<a name="pygame.time.set_timer">
  <i>repeatedly create an event on the event queue</i><br>
  <tt>pygame.time.set_timer(eventid, milliseconds): return None</tt><br>
<p>Set an event type to appear on the event queue every given number of milliseconds. The first event will not appear until the amount of time has passed. </p>
<p>Every event type can have a separate timer attached to it. It is best to use the value between <tt>pygame.USEREVENT</tt> and <tt>pygame.NUMEVENTS</tt>. </p>
<p>To disable the timer for an event, set the milliseconds argument to 0. </p>

<a name="pygame.time.Clock">
  <i>create an object to help track time</i><br>
  <tt>pygame.time.Clock(): return Clock</tt><br>
  <tr><td><a href="time.html#Clock.tick">Clock.tick</a></td><td>update the clock</td></tr>
  <tr><td><a href="time.html#Clock.get_time">Clock.get_time</a></td><td>time used in the previous tick</td></tr>
  <tr><td><a href="time.html#Clock.get_rawtime">Clock.get_rawtime</a></td><td>actual time used in the previous tick</td></tr>
  <tr><td><a href="time.html#Clock.get_fps">Clock.get_fps</a></td><td>compute the clock framerate</td></tr>
<p>Creates a new Clock object that can be used to track an amount of time. The clock also provides several functions to help control a game's framerate. </p>

<a name="Clock.tick">
  <i>update the clock</i><br>
  <tt>Clock.tick(delay=0): return milliseconds</tt><br>
<p>This method should be called once per frame. It will compute how many milliseconds have passed since the previous call. </p>
<p>If you pass an optional delay value, this function will delay until the given amount of milliseconds have passed since the previous call. This can be used to help limit the runtime speed of a game. By calling <tt>Clock.tick(1000/40)</tt> once per frame, the program will never run at more than 40 frames per second. </p>

<a name="Clock.get_time">
  <i>time used in the previous tick</i><br>
  <tt>Clock.get_time(): return milliseconds</tt><br>
<p>Returns the parameter passed to the last call to <tt><a href="time.html#Clock.tick">Clock.tick</a></tt>. It is the number of milliseconds passed between the previous two calls to <tt>Pygame.tick()</tt>. </p>

<a name="Clock.get_rawtime">
  <i>actual time used in the previous tick</i><br>
  <tt>Clock.get_rawtime(): return milliseconds</tt><br>
<p>Similar to <tt><a href="time.html#Clock.get_time">Clock.get_time</a></tt>, but this does not include any time used while <tt><a href="time.html#Clock.tick">Clock.tick</a></tt> was delaying to limit the framerate. </p>

<a name="Clock.get_fps">
  <i>compute the clock framerate</i><br>
  <tt>Clock.get_fps(): return float</tt><br>
<p>Compute your game's framerate (in frames per second). It is computed by averaging the last few calls to <tt><a href="time.html#Clock.tick">Clock.tick</a></tt>. </p>