0%

Book Description

Over 70 recipes that will help you master the elements and best practices required to build a modern game engine using Lua

In Detail

The Lua language allows developers to create everything from simple to advanced applications and to create the games they want. Creating a good game is an art, and using the right tools and knowledge is essential in making game development easier.

This book will guide you through each part of building your game engine and will help you understand how computer games are built. The book starts with simple game concepts used mainly in 2D side-scroller games, and moves on to advanced 3D games. Plus, the scripting capabilities of the Lua language give you full control over game.

By the end of this book, you will have learned all about the components that go into a game, created a game, and solved the problems that may arise along the way.

What You Will Learn

  • Set up OpenGL graphics along with GLSL shaders
  • Use lighting and graphical effects
  • Create animated game characters using Box2D library
  • Load and use textures, fonts, and 3D models
  • Design and implement a graphical user interface
  • Integrate simple Artificial Intelligence for pathfinding
  • Implement networking support
  • Use data structures in programming

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Lua Game Development Cookbook
    1. Table of Contents
    2. Lua Game Development Cookbook
    3. Credits
    4. About the Author
    5. About the Reviewer
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Sections
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Conventions
      6. Reader feedback
      7. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Basics of the Game Engine
      1. Introduction
      2. Preparing a basic file structure for the game engine
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Making a stack
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Making a queue
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Making a prioritized queue
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Extending ipairs for use in sparse arrays
        1. Getting ready
        2. How to do it…
        3. How it works…
      7. Creating Lua modules
        1. Getting ready
        2. How to do it…
          1. A module that returns a table as an interface
          2. A module in the form of an object
          3. A module in the form of a singleton object
        3. How it works…
      8. Handling errors with pcall, xpcall, and assert
        1. Getting ready
        2. How to do it…
        3. How it works…
      9. Using Lua with existing projects written in C/C++
        1. Getting ready
        2. How to do it…
          1. Initializing the Lua state
          2. Creating a Lua module in C/C++
          3. Passing variables from C/C++ into the Lua environment
          4. Passing variables from the Lua environment to C/C++
          5. Making the C++ class accessible from Lua with Lutok2
        3. How it works…
      10. Getting LuaSDL for libSDL 1.2
        1. Getting ready
        2. How to do it…
        3. There's more…
      11. Designing the main application loop with LuaSDL
        1. Getting ready
        2. How to do it…
        3. How it works…
    9. 2. Events
      1. Introduction
      2. Processing input events with LuaSDL
        1. Getting ready
        2. How to do it…
          1. Event handling with the if-then-else chain
          2. Event handling with an associative array
        3. How it works…
        4. See also
      3. Using the keyboard input
        1. Getting ready
        2. How to do it…
          1. Normal keys
          2. Modifier keys
        3. How it works…
        4. See also
      4. Using the relative mouse position
        1. Getting ready
        2. How to do it…
        3. There's more…
      5. Using the absolute mouse position
        1. How to do it…
      6. Using timers
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
    10. 3. Graphics – Common Methods
      1. Introduction
      2. Creating a window in libSDL
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Creating surfaces
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      4. Surfaces manipulation
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Using colors
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Cursor manipulation
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      7. Initializing the graphics mode with OpenGL
        1. Getting ready
        2. How to do it…
        3. How it works…
      8. Getting OpenGL information
        1. Getting ready
        2. How to do it…
          1. Getting the OpenGL version
          2. Getting the graphic card vendor
          3. Getting the graphic card name
          4. Getting the extensions list
        3. How it works…
      9. Using OpenGL extensions with GLEW and Lua
        1. Getting ready
        2. How to do it…
        3. How it works…
      10. Loading images with SDL_image
        1. Getting ready
        2. How to do it…
        3. How it works…
      11. Creating textures
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      12. Loading and using bitmap fonts
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      13. Loading and using TrueType fonts
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      14. Displaying the text
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      15. Creating texture atlas with the rover-design pattern
        1. Getting ready
        2. How to do it…
        3. How it works…
      16. Using tiles and tilesets in the game
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
    11. 4. Graphics – Legacy Method with OpenGL 1.x–2.1
      1. Introduction
      2. Drawing primitives in immediate mode
        1. Getting ready
        2. How to do it…
          1. Drawing points
          2. Drawing lines
          3. Drawing line strips
          4. Drawing line loops
          5. Drawing triangles
          6. Drawing triangle strips
          7. Drawing triangle fans
          8. Drawing quads
          9. Drawing quad strips
          10. Drawing polygons
        3. How it works…
        4. See also
      3. Setting up blending
        1. Getting ready
        2. How to do it…
          1. Additive blending
          2. Subtractive blending
          3. Alpha blending
        3. How it works…
      4. Moving, rotating, and scaling objects
        1. Getting ready
        2. How to do it…
        3. How it works…
          1. The identity matrix
          2. The translation matrix
          3. The scale matrix
          4. The rotation matrix
        4. There's more…
        5. See also
      5. Setting up the orthogonal and perspective cameras
        1. Getting ready
        2. How to do it…
          1. The orthogonal mode
          2. The perspective mode
        3. How it works…
        4. There's more…
        5. See also
      6. Setting up materials
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      7. Setting up lighting
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      8. Using display lists
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      9. Setting up the vertex buffer
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
    12. 5. Graphics – Modern Method with OpenGL 3.0+
      1. Introduction
      2. Loading and using GLSL shaders
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      3. Using uniform variables with shaders
        1. Getting ready
        2. How to do it…
          1. Writing into uniform variables
          2. Reading from uniform variables
        3. How it works…
      4. Writing a vertex shader
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      5. Writing a fragment (pixel) shader
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      6. Drawing primitives using vertex buffers
        1. Getting ready
        2. How to do it…
          1. Vertex positions
          2. Vertex colors
          3. Vertex texture coordinates
        3. How it works…
        4. There's more…
        5. See also
      7. Rendering to texture
        1. Getting ready
        2. How to do it…
          1. The render buffer with the color attachment
          2. The render buffer with the depth attachment
        3. How it works…
        4. See also
      8. Applying highlights and shadows to the scene
        1. Getting ready
        2. How to do it…
          1. Vertex shader
          2. Fragment shader
        3. How it works…
        4. See also
      9. Bumpmapping
        1. Getting ready
        2. How to do it…
          1. Vertex shader
          2. Fragment shader
        3. How it works…
        4. There's more…
        5. See also
    13. 6. The User Interface
      1. Introduction
      2. Drawing a simple window
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Moving the window
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Using the window hierarchy
        1. Getting ready
        2. How to do it…
          1. Child window rendering
          2. Event propagation
        3. How it works…
        4. See also
      5. Showing the part of the window with the stencil test and window content scrolling
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      6. Window controls and interaction
        1. Getting ready
        2. How to do it…
          1. Button
          2. Edit box
        3. How it works…
        4. There's more…
        5. See also
    14. 7. Physics and Game Mechanics
      1. Introduction
      2. Using Box2D with Lua
        1. Getting ready
        2. How to do it…
        3. How it works...
      3. Using vector math
        1. Getting ready
        2. How to do it…
        3. How it works…
      4. Choosing the correct vector scaling for the physics engine
        1. Getting ready
        2. How to do it…
        3. How it works…
      5. Creating static and dynamic objects
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      6. Setting up object properties
        1. Getting ready
        2. How to do it…
          1. Movement damping
          2. Object gravity scale
          3. Fixed rotation
          4. Object sleeping
          5. Object mass and rotational inertia
          6. Friction
          7. Restitution
          8. Density
        3. How it works…
      7. Moving objects
        1. Getting ready
        2. How to do it…
          1. The continual force
          2. Impulses
          3. Object velocity information
        3. How it works…
      8. Setting up bullets
        1. Getting ready
        2. How to do it…
        3. How it works…
      9. Running the physics simulation
        1. Getting ready
        2. How to do it…
          1. The fixed-time step
          2. The dynamic-time step
        3. How it works…
        4. There's more…
      10. Detecting object collision
        1. Getting ready
        2. How to do it…
        3. How it works…
          1. The beginContact callback
          2. The endContact callback
          3. The preSolve callback
          4. The postSolve callback
        4. There's more…
      11. Setting up object collision filtering
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
      12. Setting up object joints
        1. Getting ready
        2. How to do it…
          1. Revolute joint
          2. The prismatic joint
          3. The distance joint
          4. The rope joint
          5. The weld joint
          6. The pulley joint
          7. The wheel joint
          8. The gear joint
          9. The motor joint
          10. The mouse joint
          11. The friction joint
        3. How it works…
        4. See also
    15. 8. Artificial Intelligence
      1. Introduction
      2. A simple pathfinding algorithm for a maze
        1. Getting ready
        2. How to do it…
          1. Maze generation
          2. Maze solving
        3. How it works…
      3. Pathfinding for tile-based environments with obstacles
        1. Getting ready
        2. How to do it…
        3. How it works…
          1. Heuristic
        4. There's more…
        5. See also
      4. Using a fuzzy logic for decision making
        1. Getting ready
        2. How to do it…
          1. A fuzzy set
          2. A linguistic variable
          3. A rule
          4. A solver
          5. A usage
        3. How it works…
    16. 9. Sounds and Networking
      1. Introduction
      2. Initializing the audio subsystem
        1. Getting ready
        2. How to do it…
        3. How it works…
      3. Playing sound samples
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. There's more…
        5. See also
      4. Playing background music
        1. Getting ready
        2. How to do it…
        3. How it works…
        4. See also
      5. Network communication with ZeroMQ
        1. Getting ready
        2. How to do it…
        3. How it works…
      6. Creating a basic client-server architecture
        1. Getting ready
        2. How to do it…
          1. The server part
          2. The client part
        3. How it works…
      7. Sending messages to many hosts at once
        1. Getting ready
        2. How to do it…
          1. The publisher part
          2. The subscriber part
        3. How it works…
      8. Communication between threads
        1. Getting ready
        2. How to do it…
        3. How it works…
    17. Index
3.142.199.181