Mercurial > sdl-ios-xcode
annotate docs/html/guidetimeexamples.html @ 152:2cf88672fc7f
*** empty log message ***
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 18 Aug 2001 21:58:26 +0000 |
parents | 55f1f1b3e27d |
children | e5bc29de3f0a |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >Time Examples</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="Examples" | |
14 HREF="guideexamples.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="CDROM Examples" | |
17 HREF="guidecdromexamples.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL Reference" | |
20 HREF="reference.html"></HEAD | |
21 ><BODY | |
22 CLASS="SECT1" | |
23 BGCOLOR="#FFF8DC" | |
24 TEXT="#000000" | |
25 LINK="#0000ee" | |
26 VLINK="#551a8b" | |
27 ALINK="#ff0000" | |
28 ><DIV | |
29 CLASS="NAVHEADER" | |
30 ><TABLE | |
31 WIDTH="100%" | |
32 BORDER="0" | |
33 CELLPADDING="0" | |
34 CELLSPACING="0" | |
35 ><TR | |
36 ><TH | |
37 COLSPAN="3" | |
38 ALIGN="center" | |
39 >SDL Library Documentation</TH | |
40 ></TR | |
41 ><TR | |
42 ><TD | |
43 WIDTH="10%" | |
44 ALIGN="left" | |
45 VALIGN="bottom" | |
46 ><A | |
47 HREF="guidecdromexamples.html" | |
48 >Prev</A | |
49 ></TD | |
50 ><TD | |
51 WIDTH="80%" | |
52 ALIGN="center" | |
53 VALIGN="bottom" | |
54 >Chapter 4. Examples</TD | |
55 ><TD | |
56 WIDTH="10%" | |
57 ALIGN="right" | |
58 VALIGN="bottom" | |
59 ><A | |
60 HREF="reference.html" | |
61 >Next</A | |
62 ></TD | |
63 ></TR | |
64 ></TABLE | |
65 ><HR | |
66 ALIGN="LEFT" | |
67 WIDTH="100%"></DIV | |
68 ><DIV | |
69 CLASS="SECT1" | |
70 ><H1 | |
71 CLASS="SECT1" | |
72 ><A | |
73 NAME="GUIDETIMEEXAMPLES" | |
74 >Time Examples</A | |
75 ></H1 | |
76 ><P | |
77 ></P | |
78 ><DIV | |
79 CLASS="SECT2" | |
80 ><H2 | |
81 CLASS="SECT2" | |
82 ><A | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
83 NAME="AEN412" |
0 | 84 >Time based game loop</A |
85 ></H2 | |
86 ><P | |
87 ><PRE | |
88 CLASS="PROGRAMLISTING" | |
89 >#define TICK_INTERVAL 30 | |
90 | |
91 Uint32 TimeLeft(void) | |
92 { | |
93 static Uint32 next_time = 0; | |
94 Uint32 now; | |
95 | |
96 now = SDL_GetTicks(); | |
97 if ( next_time <= now ) { | |
98 next_time = now+TICK_INTERVAL; | |
99 return(0); | |
100 } | |
101 return(next_time-now); | |
102 } | |
103 | |
104 | |
105 /* main game loop | |
106 | |
107 while ( game_running ) { | |
108 UpdateGameState(); | |
109 SDL_Delay(TimeLeft()); | |
110 } </PRE | |
111 ></P | |
112 ></DIV | |
113 ></DIV | |
114 ><DIV | |
115 CLASS="NAVFOOTER" | |
116 ><HR | |
117 ALIGN="LEFT" | |
118 WIDTH="100%"><TABLE | |
119 WIDTH="100%" | |
120 BORDER="0" | |
121 CELLPADDING="0" | |
122 CELLSPACING="0" | |
123 ><TR | |
124 ><TD | |
125 WIDTH="33%" | |
126 ALIGN="left" | |
127 VALIGN="top" | |
128 ><A | |
129 HREF="guidecdromexamples.html" | |
130 >Prev</A | |
131 ></TD | |
132 ><TD | |
133 WIDTH="34%" | |
134 ALIGN="center" | |
135 VALIGN="top" | |
136 ><A | |
137 HREF="index.html" | |
138 >Home</A | |
139 ></TD | |
140 ><TD | |
141 WIDTH="33%" | |
142 ALIGN="right" | |
143 VALIGN="top" | |
144 ><A | |
145 HREF="reference.html" | |
146 >Next</A | |
147 ></TD | |
148 ></TR | |
149 ><TR | |
150 ><TD | |
151 WIDTH="33%" | |
152 ALIGN="left" | |
153 VALIGN="top" | |
154 >CDROM Examples</TD | |
155 ><TD | |
156 WIDTH="34%" | |
157 ALIGN="center" | |
158 VALIGN="top" | |
159 ><A | |
160 HREF="guideexamples.html" | |
161 >Up</A | |
162 ></TD | |
163 ><TD | |
164 WIDTH="33%" | |
165 ALIGN="right" | |
166 VALIGN="top" | |
167 >SDL Reference</TD | |
168 ></TR | |
169 ></TABLE | |
170 ></DIV | |
171 ></BODY | |
172 ></HTML | |
173 > |