Initial Commit.
[luagame.git] / doc / manual.lyx~
blobdff9cd3bbb363bbcacf06becc45b047174091401
1 #LyX 1.4.3 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
3 \begin_document
4 \begin_header
5 \textclass article
6 \language english
7 \inputencoding default
8 \fontscheme ae
9 \graphics default
10 \paperfontsize default
11 \spacing single
12 \papersize default
13 \use_geometry false
14 \use_amsmath 1
15 \cite_engine basic
16 \use_bibtopic false
17 \paperorientation portrait
18 \secnumdepth 3
19 \tocdepth 3
20 \paragraph_separation indent
21 \defskip medskip
22 \quotes_language english
23 \papercolumns 1
24 \papersides 1
25 \paperpagestyle default
26 \tracking_changes false
27 \output_changes false
28 \end_header
30 \begin_body
32 \begin_layout Title
33 LuaGame 1.0 Manual
34 \end_layout
36 \begin_layout Author
37 Brett Lajzer
38 \end_layout
40 \begin_layout Date
41 12.16.2006
42 \end_layout
44 \begin_layout Standard
45 \begin_inset LatexCommand \tableofcontents{}
47 \end_inset
50 \end_layout
52 \begin_layout Section
53 Introduction to LuaGame
54 \end_layout
56 \begin_layout Subsection
57 What LuaGame Does
58 \end_layout
60 \begin_layout Standard
61 LuaGame is a tool for rapid game development.
62  It is similar in scope to GameMaker, except that it is multiplatform, free,
63  and is not GUI-based.
65 \end_layout
67 \begin_layout Subsection
68 Who Should Use LuaGame
69 \end_layout
71 \begin_layout Standard
72 LuaGame has been designed for use in situations where rapid or simplified
73  development of games is neccesary.
74  That is, it's inappropriate for use by professional developers.
75  However, it is perfect for use by amateurs looking for an easy to use engine
76  that offers more control than GameMaker, is free, and will run on many
77  platforms.
78  It has been designed to be good for events known as 
79 \begin_inset Quotes eld
80 \end_inset
82 game jams
83 \begin_inset Quotes erd
84 \end_inset
86 : short, spontaneous game development contests where ease of use of the
87  development tool is very important.
88 \end_layout
90 \begin_layout Section
91 Getting Started
92 \end_layout
94 \begin_layout Subsection
95 How It Works
96 \end_layout
98 \begin_layout Standard
99 LuaGame is a C++ container to Lua that acts as a very high-level interface
100  to the SDL libraries.
102 \end_layout
104 \begin_layout Standard
105 The only required file, besides the base classes and the LuaGame executable
106  is 
107 \begin_inset Quotes eld
108 \end_inset
110 scripts/main.lua
111 \begin_inset Quotes erd
112 \end_inset
115  This file is automatically run after the base classes are initialized.
116  After the execution of this file ends, control passes back to the C++ layer,
117  cleanup is performed, and execution ends.
118 \end_layout
120 \begin_layout Subsection
121 Required Code
122 \end_layout
124 \begin_layout Standard
125 The only required code is a loop that will end when the game is supposed
126  to end.
127  In this loop, the entire game will run.
128  Input should be checked, entities should be updated and drawn, and the
129  screen updated.
130  The code should also do some sort of FPS management.
131  In the end, it should looks something like this:
132 \end_layout
134 \begin_layout Quote
135 done = false --controls the loop
136 \end_layout
138 \begin_layout Quote
139 while done ~= true do
140 \end_layout
142 \begin_deeper
143 \begin_layout Quote
144 <check input>
145 \end_layout
147 \begin_layout Quote
148 <update entities>
149 \end_layout
151 \begin_layout Quote
152 <draw entities>
153 \end_layout
155 \begin_layout Quote
156 <update screen>
157 \end_layout
159 \begin_layout Quote
160 <fps management>
161 \end_layout
163 \end_deeper
164 \begin_layout Quote
166 \end_layout
168 \begin_layout Section
169 Function Reference
170 \end_layout
172 \begin_layout Standard
173 This reference details the Lua functions.
174  The formatting is thus: <return type> <function name>(<arguments>).
175  The return type is actually rather important as in many cases it is tied
176  directly to a C/C++ type and not obeying this typing can cause some serious
177  issues.
178  All filenames should be realtive to the LuaGame executable directory.
179 \end_layout
181 \begin_layout Subsection
182 Video
183 \end_layout
185 \begin_layout Subsubsection
186 image get_image(string filename)
187 \end_layout
189 \begin_layout Standard
190 If an image is already loaded, then it returns the pointer to the image
191  surface, otherwise it loads it and returns the pointer.
192 \end_layout
194 \begin_layout Subsubsection
195 void release_image(string filename)
196 \end_layout
198 \begin_layout Standard
199 If the image has already been loaded, it will be unloaded from memory.
200  Otherwise, nothing will happen.
201 \end_layout
203 \begin_layout Subsubsection
204 void update_screen()
205 \end_layout
207 \begin_layout Standard
208 This causes the entire screen to be updated (redrawn).
209 \end_layout
211 \begin_layout Subsubsection
212 void blit(image i, int x, int y)
213 \end_layout
215 \begin_layout Standard
216 This will blit the image i to the screen at coordinates (x, y).
217  Blits do not show up until the screen is updated.
218 \end_layout
220 \begin_layout Subsubsection
221 void blit_frame(image i, int x, int y, int frame)
222 \end_layout
224 \begin_layout Standard
225 Blits the corresponding frame of the animation contained as a horizontal
226  image strip in image i.
227  Please take note that the numbering for frames starts at zero.
228  That is, the first frame is zero, the last is the number of frames minus
229  one.
230 \end_layout
232 \begin_layout Subsubsection
233 void show_cursor(boolean b)
234 \end_layout
236 \begin_layout Standard
237 If true then the mouse cursor is visible, if false then it is not.
238 \end_layout
240 \begin_layout Subsubsection
241 void fill_screen(int red, int green, int blue)
242 \end_layout
244 \begin_layout Standard
245 Fills the entire screen with the color specified by RGB components.
246 \end_layout
248 \begin_layout Subsubsection
249 image rotzoom(image i, double angle, double zoom)
250 \end_layout
252 \begin_layout Standard
253 This returns an image that has been rotated by the angle amount and zoomed
254  by the zoom amount.
255 \end_layout
257 \begin_layout Subsection
258 Sound
259 \end_layout
261 \begin_layout Subsubsection
262 void play_sample(string filename)
263 \end_layout
265 \begin_layout Standard
266 This plays a sample.
267  This should never be used to play music because it loads the entire file
268  into memory and leaves it there so that playing it the second time is much
269  faster.
270 \end_layout
272 \begin_layout Subsubsection
273 void play_music(string filename, int loop)
274 \end_layout
276 \begin_layout Standard
277 Plays music.
278  Loop is the number of times to loop.
279  -1 means loop forever, otherwise it will loop that many times.
280  If music is already playing then it will be unloaded and the new music
281  will be played.
282 \end_layout
284 \begin_layout Subsubsection
285 void stop_music()
286 \end_layout
288 \begin_layout Standard
289 Stops any currently playing music.
290 \end_layout
292 \begin_layout Subsection
293 Fonts
294 \end_layout
296 \begin_layout Subsubsection
297 font load_font(string filename, int size)
298 \end_layout
300 \begin_layout Standard
301 Loads a font.
302  Filename is the path to the font file, and size is the size (in pixels)
303  that the font should be.
304 \end_layout
306 \begin_layout Subsubsection
307 void unload_font(font f)
308 \end_layout
310 \begin_layout Standard
311 Unloads a loaded font f and releases any resources related to it.
312 \end_layout
314 \begin_layout Subsubsection
315 int w, int h rendered_string_size(font f, string s)
316 \end_layout
318 \begin_layout Standard
319 Returns two integers w and h that are the width and height of the string
320  s in the currently loaded font f (the size it would be if rendered).
321 \end_layout
323 \begin_layout Subsubsection
324 image, int w, int h render_string(font f, string s, int r, int g, int b)
325 \end_layout
327 \begin_layout Standard
328 Renders the string s in font f in color RGB(int r, int g, int b) and returns
329  the surface containing it and the width w and height h.
330 \end_layout
332 \end_body
333 \end_document