Book Image

Lua Game Development Cookbook

By : Mario Kasuba, Mário Kašuba
Book Image

Lua Game Development Cookbook

By: Mario Kasuba, Mário Kašuba

Overview of this book

Table of Contents (16 chapters)
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Surfaces manipulation


The basic surface manipulation usually consists of filling the part or whole surface with color, which can be in fact clearing the surface, and copying the surface content into another surface. As you already know, the surface can also represent the screen content. With these two groups of operations you can do almost anything.

Getting ready

In this recipe, you'll be working with routines that require a definition of a rectangular area over which the operation will occur. The libSDL library uses its own SDL_Rect object to define such a rectangular area. You can create this object either with SDL.SDL_Rect_new or SDL.SDL_Rect_local. The second one is preferred because it contains an automatic garbage collection routine, so you don't have to explicitly call the SDL.SDL_Rect_delete function to delete the object. The only downside of this is that you can't set the position nor the size of rectangle in the constructor. This means that you have to set all the parameters after...