File: time.html

package info (click to toggle)
pygame 1.9.1release%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 7,280 kB
  • ctags: 6,685
  • sloc: ansic: 41,205; python: 21,987; cpp: 537; objc: 196; php: 92; sh: 77; makefile: 41
file content (175 lines) | stat: -rw-r--r-- 10,514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175

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


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</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="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</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="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</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="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</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="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.time">
<big><b>pygame.time</big></b><br><ul>
  <i>pygame module for monitoring time</i><br>
<ul><small><table>
  <tr><td><a href="time.html#pygame.time.get_ticks">pygame.time.get_ticks</a> - <font size=-1>get the time in milliseconds</font></td><td>get the time in milliseconds</td></tr>
  <tr><td><a href="time.html#pygame.time.wait">pygame.time.wait</a> - <font size=-1>pause the program for an amount of time</font></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> - <font size=-1>pause the program for an amount of time</font></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> - <font size=-1>repeatedly create an event on the event queue</font></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> - <font size=-1>create an object to help track time</font></td><td>create an object to help track time</td></tr>
</table></small></ul>
<p>Times in pygame are represented in milliseconds (1/1000 seconds). Most platforms have a limited time resolution of around 10 milliseconds. This resolution, in milliseconds, is given in the <tt>TIMER_RESOLUTION</tt> constant. </p>
<!--COMMENTS:pygame.time--> &nbsp;<br> 


<a name="pygame.time.get_ticks">
<big><b>pygame.time.get_ticks</big></b><br><ul>
  <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> - <font size=-1>initialize all imported pygame modules</font></tt> was called. Before pygame is initialized this will always be 0. </p>
<!--COMMENTS:pygame.time.get_ticks--> &nbsp;<br> 
<br></ul>


<a name="pygame.time.wait">
<big><b>pygame.time.wait</big></b><br><ul>
  <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> - <font size=-1>pause the program for an amount of time</font></tt> function. </p>
<p>This returns the actual number of milliseconds used. </p>
<!--COMMENTS:pygame.time.wait--> &nbsp;<br> 
<br></ul>


<a name="pygame.time.delay">
<big><b>pygame.time.delay</big></b><br><ul>
  <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> - <font size=-1>pause the program for an amount of time</font></tt>. </p>
<p>This returns the actual number of milliseconds used. </p>
<!--COMMENTS:pygame.time.delay--> &nbsp;<br> 
<br></ul>


<a name="pygame.time.set_timer">
<big><b>pygame.time.set_timer</big></b><br><ul>
  <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>
<!--COMMENTS:pygame.time.set_timer--> &nbsp;<br> 
<br></ul>


<a name="pygame.time.Clock">
<big><b>pygame.time.Clock</big></b><br><ul>
  <i>create an object to help track time</i><br>
  <tt>pygame.time.Clock(): return Clock</tt><br>
<ul><small><table>
  <tr><td><a href="time.html#Clock.tick">Clock.tick</a> - <font size=-1>update the clock</font></td><td>update the clock</td></tr>
  <tr><td><a href="time.html#Clock.tick_busy_loop">Clock.tick_busy_loop</a> - <font size=-1>update the clock</font></td><td>update the clock</td></tr>
  <tr><td><a href="time.html#Clock.get_time">Clock.get_time</a> - <font size=-1>time used in the previous tick</font></td><td>time used in the previous tick</td></tr>
  <tr><td><a href="time.html#Clock.get_rawtime">Clock.get_rawtime</a> - <font size=-1>actual time used in the previous tick</font></td><td>actual time used in the previous tick</td></tr>
  <tr><td><a href="time.html#Clock.get_fps">Clock.get_fps</a> - <font size=-1>compute the clock framerate</font></td><td>compute the clock framerate</td></tr>
</table></small></ul>
<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>
<!--COMMENTS:pygame.time.Clock--> &nbsp;<br> 


<a name="Clock.tick">
<big><b>Clock.tick</big></b><br><ul>
  <i>update the clock</i><br>
  <tt>Clock.tick(framerate=0): return milliseconds</tt><br>
  <tt>control timer events</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 the optional framerate argument the function will delay to keep the game running slower than the given ticks per second. This can be used to help limit the runtime speed of a game. By calling <tt>Clock.tick(40)</tt> once per frame, the program will never run at more than 40 frames per second. </p>
<p>Note that this function uses SDL_Delay function which is not accurate on every platform, but does not use much cpu. Use tick_busy_loop if you want an accurate timer, and don't mind chewing cpu. </p>
<!--COMMENTS:Clock.tick--> &nbsp;<br> 
<br></ul>


<a name="Clock.tick_busy_loop">
<big><b>Clock.tick_busy_loop</big></b><br><ul>
  <i>update the clock</i><br>
  <tt>Clock.tick_busy_loop(framerate=0): return milliseconds</tt><br>
  <tt>control timer events</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 the optional framerate argument the function will delay to keep the game running slower than the given ticks per second. This can be used to help limit the runtime speed of a game. By calling <tt>Clock.tick(40)</tt> once per frame, the program will never run at more than 40 frames per second. </p>
<p>Note that this function uses <tt>pygame.time.delay</tt>, which uses lots of cpu in a busy loop to make sure that timing is more acurate. </p>
<p>New in pygame <tt>1.8.0</tt>. </p>
<!--COMMENTS:Clock.tick_busy_loop--> &nbsp;<br> 
<br></ul>


<a name="Clock.get_time">
<big><b>Clock.get_time</big></b><br><ul>
  <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> - <font size=-1>update the clock</font></tt>. It is the number of milliseconds passed between the previous two calls to <tt>Pygame.tick()</tt>. </p>
<!--COMMENTS:Clock.get_time--> &nbsp;<br> 
<br></ul>


<a name="Clock.get_rawtime">
<big><b>Clock.get_rawtime</big></b><br><ul>
  <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> - <font size=-1>time used in the previous tick</font></tt>, but this does not include any time used while <tt><a href="time.html#Clock.tick">Clock.tick</a> - <font size=-1>update the clock</font></tt> was delaying to limit the framerate. </p>
<!--COMMENTS:Clock.get_rawtime--> &nbsp;<br> 
<br></ul>


<a name="Clock.get_fps">
<big><b>Clock.get_fps</big></b><br><ul>
  <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> - <font size=-1>update the clock</font></tt>. </p>
<!--COMMENTS:Clock.get_fps--> &nbsp;<br> 
<br></ul>
<br></ul>
<br></ul>

</body></html>