1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.1" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
51 border-bottom: 2px solid silver
;
61 border: 1px solid silver
;
76 font-family: sans-serif
;
83 font-family: sans-serif
;
87 font-family: sans-serif
;
89 border-top: 2px solid silver
;
95 padding-bottom: 0.5em;
99 padding-bottom: 0.5em;
103 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
104 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
105 div
.admonitionblock
{
108 margin-bottom: 1.5em;
110 div
.admonitionblock
{
112 margin-bottom: 2.5em;
115 div
.content
{ /* Block element content. */
119 /* Block element titles. */
120 div
.title
, caption
.title
{
121 font-family: sans-serif
;
125 margin-bottom: 0.5em;
131 td div
.title:first-child
{
134 div
.content div
.title:first-child
{
137 div
.content
+ div
.title
{
141 div
.sidebarblock
> div
.content
{
143 border: 1px solid silver
;
150 div
.listingblock
> div
.content
{
151 border: 1px solid silver
;
156 div
.quoteblock
> div
.content
{
163 div
.verseblock
+ div
.attribution
{
167 div
.admonitionblock
.icon
{
171 text-decoration: underline
;
173 padding-right: 0.5em;
175 div
.admonitionblock td
.content
{
177 border-left: 2px solid silver
;
180 div
.exampleblock
> div
.content
{
181 border-left: 2px solid silver
;
185 div
.verseblock div
.content
{
189 div
.imageblock div
.content
{ padding-left: 0; }
190 div
.imageblock img
{ border: 1px solid silver
; }
191 span
.image img
{ border-style: none
; }
195 margin-bottom: 0.8em;
207 list-style-position: outside
;
210 list-style-type: lower-alpha
;
213 div
.tableblock
> table
{
214 border: 3px solid
#527bbd;
217 font-family: sans-serif
;
226 margin-bottom: 0.8em;
234 padding-right: 0.8em;
241 div#footer-badges
{ display: none
; }
246 font-family: sans-serif
;
250 margin-bottom: 0.1em;
253 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
269 /* Workarounds for IE6's broken and incomplete CSS2. */
271 div
.sidebar-content
{
273 border: 1px solid silver
;
276 div
.sidebar-title
, div
.image-title
{
277 font-family: sans-serif
;
280 margin-bottom: 0.5em;
283 div
.listingblock div
.content
{
284 border: 1px solid silver
;
289 div
.quoteblock-content
{
293 div
.exampleblock-content
{
294 border-left: 2px solid silver
;
298 /* IE6 sets dynamically generated links as visited. */
299 div#toc
a:visited
{ color: blue
; }
301 <script type=
"text/javascript">
303 window
.onload = function(){generateToc(2)}
304 /* Author: Mihai Bazon, September 2002
305 * http://students.infoiasi.ro/~mishoo
307 * Table Of Content generator
310 * Feel free to use this script under the terms of the GNU General Public
311 * License, as long as you do not remove or alter this notice.
314 /* modified by Troy D. Hanson, September 2006. License: GPL */
315 /* modified by Stuart Rackham, October 2006. License: GPL */
317 function getText(el
) {
319 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
320 if (i
.nodeType
== 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
322 else if (i
.firstChild
!= null)
328 function TocEntry(el
, text
, toclevel
) {
331 this.toclevel
= toclevel
;
334 function tocEntries(el
, toclevels
) {
335 var result
= new Array
;
336 var re
= new RegExp('[hH]([2-'+(toclevels
+1)+'])');
337 // Function that scans the DOM tree for header elements (the DOM2
338 // nodeIterator API would be a better technique but not supported by all
340 var iterate = function (el
) {
341 for (var i
= el
.firstChild
; i
!= null; i
= i
.nextSibling
) {
342 if (i
.nodeType
== 1 /* Node.ELEMENT_NODE */) {
343 var mo
= re
.exec(i
.tagName
)
345 result
[result
.length
] = new TocEntry(i
, getText(i
), mo
[1]-1);
354 // This function does the work. toclevels = 1..4.
355 function generateToc(toclevels
) {
356 var toc
= document
.getElementById("toc");
357 var entries
= tocEntries(document
.getElementsByTagName("body")[0], toclevels
);
358 for (var i
= 0; i
< entries
.length
; ++i
) {
359 var entry
= entries
[i
];
360 if (entry
.element
.id
== "")
361 entry
.element
.id
= "toc" + i
;
362 var a
= document
.createElement("a");
363 a
.href
= "#" + entry
.element
.id
;
364 a
.appendChild(document
.createTextNode(entry
.text
));
365 var div
= document
.createElement("div");
367 div
.className
= "toclevel" + entry
.toclevel
;
368 toc
.appendChild(div
);
373 <title>LuaGame Function Reference
</title>
377 <h1>LuaGame Function Reference
</h1>
379 <div id=
"toctitle">Table of Contents
</div>
380 <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.
</b></p></noscript>
383 <h2>1. Conventions
</h2>
384 <div class=
"sectionbody">
385 <p>Arguments and return values are formatted:
<strong>name
<type
></strong>.
</p>
386 <p>A return value of
<strong><varying
></strong> means that the function can
387 return a variable number of arguments. This will usually
388 be explained in the description of the function.
</p>
391 <div class=
"sectionbody">
392 <h3>2.1. image
<SDL_Surface*
> get_image(path
<string
>)
</h3>
393 <p>Returns an SDL_Surface* to the image referenced by
<strong>path
</strong>.
394 If image has not been loaded before, it is loaded. If it has,
395 the pointer is returned.
</p>
396 <h3>2.2. release_image(path
<string
>)
</h3>
397 <p>Causes a loaded image to be freed from memory.
398 This is especially useful if one loads an image that is
399 only used for a small portion of the game because normally, an image
400 will stay loaded in memory forever.
</p>
401 <h3>2.3. update_screen()
</h3>
402 <p>Causes the screen surface in video memory to be updated from
403 the backbuffer or surface in main memory. This is basically
404 a call to
<em>SDL_Flip()
</em>.
</p>
405 <h3>2.4. blit(image
<SDL_Surface*
>, x
<int
>, y
<int
>, rotation
<double
>, reposition
<bool
>, smoothing
<bool
>)
</h3>
406 <p>Blits
<strong>image
</strong> to the screen at position
<strong>(x, y)
</strong>. If
<strong>rotation
</strong> is non-zero, the image will be rotated on the fly.
407 If
<strong>reposition
</strong> is true, the rotated image will be re-centered (you probably want this).
<strong>Smoothing
</strong> is whether or
408 not linear interpolation should be used (looks pretty but eats CPU).
</p>
409 <h3>2.5. blit_frame(image
<SDL_Surface*
>, x
<int
>, y
<int
>, frames
<int
>, frame_num
<int
>)
</h3>
410 <p>Blits frame
<strong>frame_num
</strong> to the screen at position
<strong>(x, y)
</strong> from
<strong>image
</strong> with
<strong>frames
</strong> number of frames.
</p>
411 <h3>2.6. show_cursor(show
<bool
>)
</h3>
412 <p>Turns on/off the display of the cursor.
</p>
413 <h3>2.7. fill_screen(R
<int
>, G
<int
>, B
<int
>)
</h3>
414 <p>Fills the screen with the color specified by the rgb triplet
<strong>(R,G,B)
</strong>.
</p>
415 <h3>2.8. delete_image(image
<SDL_Surface*
>)
</h3>
416 <p>This effectively calls SDL_FreeSurface() on
<strong>image
</strong>. This function
417 should
<em>never
</em> be used on an image loaded using
<em>get_image()
</em>.
</p>
418 <h3>2.9. rz_image
<SDL_Surface*
>, w
<int
>, h
<int
> rotzoom(image
<SDL_Surface*
>, angle
<double
>, zoom
<double
>)
</h3>
419 <p>Returns a rotated and/or zoomed version of
<strong>image
</strong> and also the width
<strong>w
</strong> and height
<strong>h
</strong> of the rotated/zoomed image.
420 <strong>Angle
</strong> is specified in degrees.
<strong>Zoom
</strong> is the scaling factor.
421 Surfaces returned by this function should be freed after use using
<em>delete_image()
</em>.
</p>
424 <div class=
"sectionbody">
425 <h3>3.1. ticks
<int
> get_ticks()
</h3>
426 <p>Returns the number of milliseconds since program intialization. This value overflows after
49 days (
32-bit integer).
</p>
427 <h3>3.2. delay(time
<int
>)
</h3>
428 <p>Waits for
<strong>time
</strong> milliseconds and then returns.
</p>
431 <div class=
"sectionbody">
432 <h3>4.1. x
<int
>, y
<int
>, left
<bool
>, right
<bool
> mouse_state()
</h3>
433 <p>Returns the absolute position (within the window) of the cursor.
434 It also returns the state of the left and right mouse buttons.
435 This function can be used to get the state of the mouse even when
436 and event manager is in use.
</p>
437 <h3>4.2. num
<int
> num_joysticks()
</h3>
438 <p>Returns the number of joysticks currently attached to the system.
</p>
439 <h3>4.3.
<varying
> get_event()
</h3>
440 <p>This function is used by the event manager to pass events
441 from SDL to Lua. It should never need to be explicitly
442 called by the programmer. It returns a varying number of
446 <div class=
"sectionbody">
447 <h3>5.1. sample
<Mix_Chunk*
> load_sample(path
<string
>)
</h3>
448 <p>Loads a sample, specified by
<strong>path
</strong>, and returns a pointer to it.
</p>
449 <h3>5.2. unload_sample(path
<string
>)
</h3>
450 <p>Unloads a previously loaded sample specified by
<strong>path
</strong>.
</p>
451 <h3>5.3. play_sample(sample
<Mix_Chunk*
>)
</h3>
452 <p>Plays the sample specified by
<strong>sample
</strong>. The sample will play until completion.
453 Sample needs to have been previously loaded using load_sample().
</p>
454 <h3>5.4. clear_samples()
</h3>
455 <p>Unloads all loaded samples from memory.
</p>
456 <h3>5.5. stop_samples()
</h3>
457 <p>Stops the playback of all currently playing samples.
</p>
458 <h3>5.6. play_music(path
<string
>, loops
<int
>)
</h3>
459 <p>Plays music specified by
<strong>path
</strong>. Music will play
<strong>loops
</strong> times. If
<strong>loops
</strong> is -
1 then it will loop continuously until stopped.
</p>
460 <h3>5.7. stop_music()
</h3>
461 <p>Stops the currently playing music.
</p>
464 <div class=
"sectionbody">
465 <h3>6.1. draw_pixel(x
<int
>, y
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
466 <p>Draws a pixel of color
<strong>rgb(R,G,B)
</strong> at position
<strong>(x,y)
</strong>.
</p>
467 <h3>6.2. draw_line(x1
<int
>, y1
<int
>, x2
<int
>, y2
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
468 <p>Draws a line of color
<strong>rgb(R,G,B)
</strong> from
<strong>(x1,y1)
</strong> to
<strong>(x2,y2)
</strong>.
</p>
469 <h3>6.3. draw_rect(x1
<int
>, y1
<int
>, x2
<int
>, y2
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
470 <p>Draws a rectangle of color
<strong>rgb(R,G,B)
</strong> with top left corner
<strong>(x1,y1)
</strong> and bottom right corner
<strong>(x2,y2)
</strong>.
</p>
471 <h3>6.4. draw_filled_rect(x1
<int
>, y1
<int
>, x2
<int
>, y2
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
472 <p>Draws a filled rectangle of color
<strong>rgb(R,G,B)
</strong> with top left corner
<strong>(x1,y1)
</strong> and bottom right corner
<strong>(x2,y2)
</strong>.
</p>
473 <h3>6.5. draw_circle(x
<int
>, y
<int
>, rad
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
474 <p>Draws a circle of color
<strong>rgb(R,G,B)
</strong> with center at position
<strong>(x,y)
</strong> and radius of
<strong>rad
</strong>.
</p>
475 <h3>6.6. draw_filled_circle(x
<int
>, y
<int
>, rad
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
476 <p>Draws a filled circle of color
<strong>rgb(R,G,B)
</strong> with center at position
<strong>(x,y)
</strong> and radius of
<strong>rad
</strong>.
</p>
477 <h3>6.7. draw_ellipse(x
<int
>, y
<int
>, x_rad
<int
>, y_rad
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
478 <p>Draws an ellipse of color
<strong>rgb(R,G,B)
</strong> with center at position
<strong>(x,y)
</strong>, x radius of
<strong>x_rad
</strong> and y radius of
<strong>y_rad
</strong>.
</p>
479 <h3>6.8. draw_filled_ellipse(x
<int
>, y
<int
>, x_rad
<int
>, y_rad
<int
>, R
<int
>, G
<int
>, B
<int
>, Alpha
<int
>)
</h3>
480 <p>Draws a filled ellipse of color
<strong>rgb(R,G,B)
</strong> with center at position
<strong>(x,y)
</strong>, x radius of
<strong>x_rad
</strong> and y radius of
<strong>y_rad
</strong>.
</p>
483 <div class=
"sectionbody">
484 <h3>7.1. font
<TTF_Font*
> load_font(path
<string
>, size
<int
>)
</h3>
485 <p>Loads a font specified by
<strong>path
</strong> at size
<strong>size
</strong>.
</p>
486 <h3>7.2. unload_font(font
<TTF_Font*
>)
</h3>
487 <p>Unloads a font specified by
<strong>font
</strong>.
</p>
488 <h3>7.3. w
<int
>, h
<int
> rendered_string_size(font
<TTF_Font*
>, text
<string
>)
</h3>
489 <p>Returns the width
<strong>w
</strong> and height
<strong>h
</strong> of the string
<strong>text
</strong> as rendered in
<strong>font
</strong>.
</p>
490 <h3>7.4. txt_image
<SDL_Surface*
> render_string(font
<TTF_Font*
>, text
<string
>, R
<int
>, G
<int
>, B
<int
>)===
</h3>
491 <p>Renders string
<strong>text
</strong> in the specified
<strong>font
</strong> and color
<strong>rgb(R,G,B)
</strong> and returns it as an SDL_Surface.
</p>
494 <div id=
"footer-text">
495 Last updated
23-Oct-
2007 18:
28:
50 EDT