Finished ParticleSystem and delta-animation support.
[luagame.git] / doc / fun_ref.txt
blob9dcc11aee1e25c378bdf5fa3c5da642b5ca02ff3
1 LuaGame Function Reference
2 ==========================
4 == Conventions ==
5 Arguments and return values are formatted: **name<type>**.
7 A return value of *<varying>* means that the function can
8 return a variable number of arguments. This will usually
9 be explained in the description of the function.
12 == Video ==
13 === image<SDL_Surface*> get_image(path<string>) ===
14 Returns an SDL_Surface* to the image referenced by *path*.
15 If image has not been loaded before, it is loaded. If it has,
16 the pointer is returned.
18 === release_image(path<string>) ===
19 Causes a loaded image to be freed from memory.
20 This is especially useful if one loads an image that is
21 only used for a small portion of the game because normally, an image
22 will stay loaded in memory forever.
24 === update_screen() ===
25 Causes the screen surface in video memory to be updated from
26 the backbuffer or surface in main memory. This is basically
27 a call to _SDL_Flip()_.
29 === r<int>, g<int>, b<int>, a<int> get_pixel(image<SDL_Surface*>, x<int>, y<int>) ===
30 Returns the RGBA color components of the pixel at position *(x, y)* in *image*.
32 === blit(image<SDL_Surface*>, x<int>, y<int>) ===
33 Blits *image* to the screen at position *(x, y)*.
35 === blit_frame(image<SDL_Surface*>, x<int>, y<int>, frames<int>, frame_num<int>) ===
36 Blits frame *frame_num* to the screen at position *(x, y)* from *image* with *frames* number of frames.
38 === show_cursor(show<bool>) ===
39 Turns on/off the display of the cursor.
41 === fill_screen(R<int>, G<int>, B<int>) ===
42 Fills the screen with the color specified by the rgb triplet *(R,G,B)*.
44 === delete_image(image<SDL_Surface*>) ===
45 This effectively calls SDL_FreeSurface() on *image*. This function
46 should _never_ be used on an image loaded using _get_image()_.
48 === rz_image<SDL_Surface*>, w<int>, h<int> rotzoom(image<SDL_Surface*>, angle<double>, zoom<double>) ===
49 Returns a rotated and/or zoomed version of *image* and also the width *w* and height *h* of the rotated/zoomed image.
50 *Angle* is specified in degrees. *Zoom* is the scaling factor.
51 Surfaces returned by this function should be freed after use using _delete_image()_.
54 == Misc ==
55 === ticks<int> get_ticks() ===
56 Returns the number of milliseconds since program intialization.
58 === delay(time<int>) ===
59 Waits for *time* milliseconds and then returns.
62 == Input ==
63 === x<int>, y<int>, left<bool>, right<bool> mouse_state() ===
64 Returns the absolute position (within the window) of the cursor.
65 It also returns the state of the left and right mouse buttons.
66 This function can be used to get the state of the mouse even when
67 and event manager is in use.
69 === num<int> num_joysticks() ===
70 Returns the number of joysticks currently attached to the system.
72 === <varying> get_event() ===
73 This function is used by the event manager to pass events
74 from SDL to Lua. It should never need to be explicitly
75 called by the programmer. It returns a varying number of
76 arguments.
79 == Sound ==
80 === play_sample(path<string>) ===
81 Plays the sample specified by *path*. The sample will play until completion.
83 === play_music(path<string>, loops<int>) ===
84 Plays music specified by *path*. Music will play *loops* times. If *loops* is -1 then it will loop forever.
86 === stop_music() ===
87 Stops the currently playing music.
90 == Drawing ==
91 === draw_pixel(x<int>, y<int>, R<int>, G<int>, B<int>) ===
92 Draws a pixel of color *rgb(R,G,B)* at position *(x,y)*.
94 === draw_line(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>) ===
95 Draws a line of color *rgb(R,G,B)* from *(x1,y1)* to *(x2,y2)*.
97 === draw_rect(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>) ===
98 Draws a rectangle of color *rgb(R,G,B)* with top left corner *(x1,y1)* and bottom right corner *(x2,y2)*.
100 === draw_filled_rect(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>) ===
101 Draws a filled rectangle of color *rgb(R,G,B)* with top left corner *(x1,y1)* and bottom right corner *(x2,y2)*.
103 === draw_circle(x<int>, y<int>, rad<int>, R<int>, G<int>, B<int>) ===
104 Draws a circle of color *rgb(R,G,B)* with center at position *(x,y)* and radius of *rad*.
106 === draw_filled_circle(x<int>, y<int>, rad<int>, R<int>, G<int>, B<int>) ===
107 Draws a filled circle of color *rgb(R,G,B)* with center at position *(x,y)* and radius of *rad*.
109 === draw_ellipse(x<int>, y<int>, x_rad<int>, y_rad<int>, R<int>, G<int>, B<int>) ===
110 Draws an ellipse of color *rgb(R,G,B)* with center at position *(x,y)*, x radius of *x_rad* and y radius of *y_rad*.
112 === draw_filled_ellipse(x<int>, y<int>, x_rad<int>, y_rad<int>, R<int>, G<int>, B<int>) ===
113 Draws a filled ellipse of color *rgb(R,G,B)* with center at position *(x,y)*, x radius of *x_rad* and y radius of *y_rad*.
116 == Font ==
117 === font<TTF_Font*> load_font(path<string>, size<int>) ===
118 Loads a font specified by *path* at size *size*.
120 === unload_font(font<TTF_Font*>) ===
121 Unloads a font specified by *font*.
123 === w<int>, h<int> rendered_string_size(font<TTF_Font*>, text<string>) ===
124 Returns the width *w* and height *h* of the string *text* as rendered in *font*.