Mercurial > sdl-ios-xcode
annotate docs/html/guidetimeexamples.html @ 610:95433459fbd2
Date: Mon, 14 Apr 2003 22:08:27 +0100
From: Patrice Mandin
Subject: [SDL][PATCH] 2 patches for sdl
Here are 2 patches for SDL:
- One is to put the dummy video drivers at the end of the
video drivers list. It gave me problems, when
SDL_VIDEODRIVER is not set, and the dummy driver is used
instead of the platform's driver, just because it is
always available. So the dummy driver must always be at
the end of the list. I suppose picogui and dc video
drivers also don't work.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 15 Apr 2003 15:46:56 +0000 |
parents | e5bc29de3f0a |
children | 355632dca928 |
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 | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
91 static Uint32 next_time; |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
92 |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
93 Uint32 time_left(void) |
0 | 94 { |
95 Uint32 now; | |
96 | |
97 now = SDL_GetTicks(); | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
98 if(next_time <= now) |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
99 return 0; |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
100 else |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
101 return next_time - now; |
0 | 102 } |
103 | |
104 | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
105 /* main game loop */ |
0 | 106 |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
107 next_time = SDL_GetTicks() + TICK_INTERVAL; |
0 | 108 while ( game_running ) { |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
109 update_game_state(); |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
110 SDL_Delay(time_left()); |
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
111 next_time += TICK_INTERVAL; |
0 | 112 } </PRE |
113 ></P | |
114 ></DIV | |
115 ></DIV | |
116 ><DIV | |
117 CLASS="NAVFOOTER" | |
118 ><HR | |
119 ALIGN="LEFT" | |
120 WIDTH="100%"><TABLE | |
121 WIDTH="100%" | |
122 BORDER="0" | |
123 CELLPADDING="0" | |
124 CELLSPACING="0" | |
125 ><TR | |
126 ><TD | |
127 WIDTH="33%" | |
128 ALIGN="left" | |
129 VALIGN="top" | |
130 ><A | |
131 HREF="guidecdromexamples.html" | |
132 >Prev</A | |
133 ></TD | |
134 ><TD | |
135 WIDTH="34%" | |
136 ALIGN="center" | |
137 VALIGN="top" | |
138 ><A | |
139 HREF="index.html" | |
140 >Home</A | |
141 ></TD | |
142 ><TD | |
143 WIDTH="33%" | |
144 ALIGN="right" | |
145 VALIGN="top" | |
146 ><A | |
147 HREF="reference.html" | |
148 >Next</A | |
149 ></TD | |
150 ></TR | |
151 ><TR | |
152 ><TD | |
153 WIDTH="33%" | |
154 ALIGN="left" | |
155 VALIGN="top" | |
156 >CDROM Examples</TD | |
157 ><TD | |
158 WIDTH="34%" | |
159 ALIGN="center" | |
160 VALIGN="top" | |
161 ><A | |
162 HREF="guideexamples.html" | |
163 >Up</A | |
164 ></TD | |
165 ><TD | |
166 WIDTH="33%" | |
167 ALIGN="right" | |
168 VALIGN="top" | |
169 >SDL Reference</TD | |
170 ></TR | |
171 ></TABLE | |
172 ></DIV | |
173 ></BODY | |
174 ></HTML | |
175 > |