售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
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
How it works…
There's more…
See also
6. The User Interface
Introduction
Drawing a simple window
Getting ready
How to do it…
How it works…
Moving the window
Getting ready
How to do it…
How it works…
Using the window hierarchy
Getting ready
How to do it…
Child window rendering
Event propagation
How it works…
See also
Showing the part of the window with the stencil test and window content scrolling
Getting ready
How to do it…
How it works…
See also
Window controls and interaction
Getting ready
How to do it…
Button
Edit box
How it works…
There's more…
See also
7. Physics and Game Mechanics
Introduction
Using Box2D with Lua
Getting ready
How to do it…
How it works...
Using vector math
Getting ready
How to do it…
How it works…
Choosing the correct vector scaling for the physics engine
Getting ready
How to do it…
How it works…
Creating static and dynamic objects
Getting ready
How to do it…
How it works…
There's more…
Setting up object properties
Getting ready
How to do it…
Movement damping
Object gravity scale
Fixed rotation
Object sleeping
Object mass and rotational inertia
Friction
Restitution
Density
How it works…
Moving objects
Getting ready
How to do it…
The continual force
Impulses
Object velocity information
How it works…
Setting up bullets
Getting ready
How to do it…
How it works…
Running the physics simulation
Getting ready
How to do it…
The fixed-time step
The dynamic-time step
How it works…
There's more…
Detecting object collision
Getting ready
How to do it…
How it works…
The beginContact callback
The endContact callback
The preSolve callback
The postSolve callback
There's more…
Setting up object collision filtering
Getting ready
How to do it…
How it works…
There's more…
Setting up object joints
Getting ready
How to do it…
Revolute joint
The prismatic joint
The distance joint
The rope joint
The weld joint
The pulley joint
The wheel joint
The gear joint
The motor joint
The mouse joint
The friction joint
How it works…
See also
8. Artificial Intelligence
Introduction
A simple pathfinding algorithm for a maze
Getting ready
How to do it…
Maze generation
Maze solving
How it works…
Pathfinding for tile-based environments with obstacles
Getting ready
How to do it…
How it works…
Heuristic
There's more…
See also
Using a fuzzy logic for decision making
Getting ready
How to do it…
A fuzzy set
A linguistic variable
A rule
A solver
A usage
How it works…
9. Sounds and Networking
Introduction
Initializing the audio subsystem
Getting ready
How to do it…
How it works…
Playing sound samples
Getting ready
How to do it…
How it works…
There's more…
See also
Playing background music
Getting ready
How to do it…
How it works…
See also
Network communication with ZeroMQ
Getting ready
How to do it…
How it works…
Creating a basic client-server architecture
Getting ready
How to do it…
The server part
The client part
How it works…
Sending messages to many hosts at once
Getting ready
How to do it…
The publisher part
The subscriber part
How it works…
Communication between threads
Getting ready
How to do it…
How it works…
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜