1. Conventions

Arguments and return values are formatted: name<type>.

A return value of <varying> means that the function can return a variable number of arguments. This will usually be explained in the description of the function.

2. Video

2.1. image<SDL_Surface*> get_image(path<string>)

Returns an SDL_Surface* to the image referenced by path. If image has not been loaded before, it is loaded. If it has, the pointer is returned.

2.2. release_image(path<string>)

Causes a loaded image to be freed from memory. This is especially useful if one loads an image that is only used for a small portion of the game because normally, an image will stay loaded in memory forever.

2.3. update_screen()

Causes the screen surface in video memory to be updated from the backbuffer or surface in main memory. This is basically a call to SDL_Flip().

2.4. blit(image<SDL_Surface*>, x<int>, y<int>, rotation<double>, reposition<bool>, smoothing<bool>)

Blits image to the screen at position (x, y). If rotation is non-zero, the image will be rotated on the fly. If reposition is true, the rotated image will be re-centered (you probably want this). Smoothing is whether or not linear interpolation should be used (looks pretty but eats CPU).

2.5. blit_frame(image<SDL_Surface*>, x<int>, y<int>, frames<int>, frame_num<int>)

Blits frame frame_num to the screen at position (x, y) from image with frames number of frames.

2.6. show_cursor(show<bool>)

Turns on/off the display of the cursor.

2.7. fill_screen(R<int>, G<int>, B<int>)

Fills the screen with the color specified by the rgb triplet (R,G,B).

2.8. delete_image(image<SDL_Surface*>)

This effectively calls SDL_FreeSurface() on image. This function should never be used on an image loaded using get_image().

2.9. rz_image<SDL_Surface*>, w<int>, h<int> rotzoom(image<SDL_Surface*>, angle<double>, zoom<double>)

Returns a rotated and/or zoomed version of image and also the width w and height h of the rotated/zoomed image. Angle is specified in degrees. Zoom is the scaling factor. Surfaces returned by this function should be freed after use using delete_image().

3. Misc

3.1. ticks<int> get_ticks()

Returns the number of milliseconds since program intialization. This value overflows after 49 days (32-bit integer).

3.2. delay(time<int>)

Waits for time milliseconds and then returns.

4. Input

4.1. x<int>, y<int>, left<bool>, right<bool> mouse_state()

Returns the absolute position (within the window) of the cursor. It also returns the state of the left and right mouse buttons. This function can be used to get the state of the mouse even when and event manager is in use.

4.2. num<int> num_joysticks()

Returns the number of joysticks currently attached to the system.

4.3. <varying> get_event()

This function is used by the event manager to pass events from SDL to Lua. It should never need to be explicitly called by the programmer. It returns a varying number of results.

5. Sound

5.1. sample<Mix_Chunk*> load_sample(path<string>)

Loads a sample, specified by path, and returns a pointer to it.

5.2. unload_sample(path<string>)

Unloads a previously loaded sample specified by path.

5.3. play_sample(sample<Mix_Chunk*>)

Plays the sample specified by sample. The sample will play until completion. Sample needs to have been previously loaded using load_sample().

5.4. clear_samples()

Unloads all loaded samples from memory.

5.5. stop_samples()

Stops the playback of all currently playing samples.

5.6. play_music(path<string>, loops<int>)

Plays music specified by path. Music will play loops times. If loops is -1 then it will loop continuously until stopped.

5.7. stop_music()

Stops the currently playing music.

6. Drawing

6.1. draw_pixel(x<int>, y<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a pixel of color rgb(R,G,B) at position (x,y).

6.2. draw_line(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a line of color rgb(R,G,B) from (x1,y1) to (x2,y2).

6.3. draw_rect(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a rectangle of color rgb(R,G,B) with top left corner (x1,y1) and bottom right corner (x2,y2).

6.4. draw_filled_rect(x1<int>, y1<int>, x2<int>, y2<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a filled rectangle of color rgb(R,G,B) with top left corner (x1,y1) and bottom right corner (x2,y2).

6.5. draw_circle(x<int>, y<int>, rad<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a circle of color rgb(R,G,B) with center at position (x,y) and radius of rad.

6.6. draw_filled_circle(x<int>, y<int>, rad<int>, R<int>, G<int>, B<int>, Alpha<int>)

Draws a filled circle of color rgb(R,G,B) with center at position (x,y) and radius of rad.

6.7. draw_ellipse(x<int>, y<int>, x_rad<int>, y_rad<int>, R<int>, G<int>, B<int>, Alpha<int>)

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.

6.8. draw_filled_ellipse(x<int>, y<int>, x_rad<int>, y_rad<int>, R<int>, G<int>, B<int>, Alpha<int>)

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.

7. Font

7.1. font<TTF_Font*> load_font(path<string>, size<int>)

Loads a font specified by path at size size.

7.2. unload_font(font<TTF_Font*>)

Unloads a font specified by font.

7.3. w<int>, h<int> rendered_string_size(font<TTF_Font*>, text<string>)

Returns the width w and height h of the string text as rendered in font.

7.4. txt_image<SDL_Surface*> render_string(font<TTF_Font*>, text<string>, R<int>, G<int>, B<int>)===

Renders string text in the specified font and color rgb(R,G,B) and returns it as an SDL_Surface.