Lua Game Development Cookbook
Table of Contents
Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why Subscribe?
Free Access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Basics of the Game Engine
Introduction
Preparing a basic file structure for the game engine
Getting ready
How to do itā¦
How it worksā¦
Making a stack
Getting ready
How to do itā¦
How it worksā¦
Making a queue
Getting ready
How to do itā¦
How it worksā¦
Making a prioritized queue
Getting ready
How to do itā¦
How it worksā¦
Extending ipairs for use in sparse arrays
Getting ready
How to do itā¦
How it worksā¦
Creating Lua modules
Getting ready
How to do itā¦
A module that returns a table as an interface
A module in the form of an object
A module in the form of a singleton object
How it worksā¦
Handling errors with pcall, xpcall, and assert
Getting ready
How to do itā¦
How it worksā¦
Using Lua with existing projects written in C/C++
Getting ready
How to do itā¦
Initializing the Lua state
Creating a Lua module in C/C++
Passing variables from C/C++ into the Lua environment
Passing variables from the Lua environment to C/C++
Making the C++ class accessible from Lua with Lutok2
How it worksā¦
Getting LuaSDL for libSDL 1.2
Getting ready
How to do itā¦
There's moreā¦
Designing the main application loop with LuaSDL
Getting ready
How to do itā¦
How it worksā¦
2. Events
Introduction
Processing input events with LuaSDL
Getting ready
How to do itā¦
Event handling with the if-then-else chain
Event handling with an associative array
How it worksā¦
See also
Using the keyboard input
Getting ready
How to do itā¦
Normal keys
Modifier keys
How it worksā¦
See also
Using the relative mouse position
Getting ready
How to do itā¦
There's moreā¦
Using the absolute mouse position
How to do itā¦
Using timers
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
3. Graphics ā Common Methods
Introduction
Creating a window in libSDL
Getting ready
How to do itā¦
How it worksā¦
Creating surfaces
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Surfaces manipulation
Getting ready
How to do itā¦
How it worksā¦
Using colors
Getting ready
How to do itā¦
How it worksā¦
Cursor manipulation
Getting ready
How to do itā¦
How it worksā¦
See also
Initializing the graphics mode with OpenGL
Getting ready
How to do itā¦
How it worksā¦
Getting OpenGL information
Getting ready
How to do itā¦
Getting the OpenGL version
Getting the graphic card vendor
Getting the graphic card name
Getting the extensions list
How it worksā¦
Using OpenGL extensions with GLEW and Lua
Getting ready
How to do itā¦
How it worksā¦
Loading images with SDL_image
Getting ready
How to do itā¦
How it worksā¦
Creating textures
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
Loading and using bitmap fonts
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Loading and using TrueType fonts
Getting ready
How to do itā¦
How it worksā¦
See also
Displaying the text
Getting ready
How to do itā¦
How it worksā¦
See also
Creating texture atlas with the rover-design pattern
Getting ready
How to do itā¦
How it worksā¦
Using tiles and tilesets in the game
Getting ready
How to do itā¦
How it worksā¦
See also
4. Graphics ā Legacy Method with OpenGL 1.xā2.1
Introduction
Drawing primitives in immediate mode
Getting ready
How to do itā¦
Drawing points
Drawing lines
Drawing line strips
Drawing line loops
Drawing triangles
Drawing triangle strips
Drawing triangle fans
Drawing quads
Drawing quad strips
Drawing polygons
How it worksā¦
See also
Setting up blending
Getting ready
How to do itā¦
Additive blending
Subtractive blending
Alpha blending
How it worksā¦
Moving, rotating, and scaling objects
Getting ready
How to do itā¦
How it worksā¦
The identity matrix
The translation matrix
The scale matrix
The rotation matrix
There's moreā¦
See also
Setting up the orthogonal and perspective cameras
Getting ready
How to do itā¦
The orthogonal mode
The perspective mode
How it worksā¦
There's moreā¦
See also
Setting up materials
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Setting up lighting
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Using display lists
Getting ready
How to do itā¦
How it worksā¦
See also
Setting up the vertex buffer
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
5. Graphics ā Modern Method with OpenGL 3.0+
Introduction
Loading and using GLSL shaders
Getting ready
How to do itā¦
How it worksā¦
See also
Using uniform variables with shaders
Getting ready
How to do itā¦
Writing into uniform variables
Reading from uniform variables
How it worksā¦
Writing a vertex shader
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Writing a fragment (pixel) shader
Getting ready
How to do itā¦
How it worksā¦
There's moreā¦
See also
Drawing primitives using vertex buffers
Getting ready
How to do itā¦
Vertex positions
Vertex colors
Vertex texture coordinates
How it worksā¦
There's moreā¦
See also
Rendering to texture
Getting ready
How to do itā¦
The render buffer with the color attachment
The render buffer with the depth attachment
How it worksā¦
See also
Applying highlights and shadows to the scene
Getting ready
How to do itā¦
Vertex shader
Fragment shader
How it worksā¦
See also
Bumpmapping
Getting ready
How to do itā¦
Vertex shader
Fragment shader
Ho...