Book Image

L÷VE for Lua Game Programming

By : AKINLAJA DAMILARE JOSHUA
1 (1)
Book Image

L÷VE for Lua Game Programming

1 (1)
By: AKINLAJA DAMILARE JOSHUA

Overview of this book

L?ñVE is a game development framework for making 2D games using the Lua programming language. L?ñVE is totally free, and can be used in anything from friendly open-source hobby projects, to closed-source commercial ones. Using the Lua programming framework, one can use L?ñVE2D to make any sort of interesting games. L?ñVE for Lua Game Programming will quickly and efficiently guide you through how to develop a video game from idea to prototype. Even if you are new to game programming, with this book, you will soon be able to create as many game titles as you wish without stress. The L?ñVE framework is the quickest and easiest way to build fully-functional 2D video games. It leverages the Lua programming language, which is known to be one of the easiest game development languages to learn and use. With this book, you will master how to develop multi-platform games for Windows, Linux, and Mac OS X. After downloading and installing L?ñVE, you will learn by example how to draw 2D objects, animate characters using sprites, and how to create game physics and game world maps. L?ñVE for Lua Game Programming makes it easier and quicker for you to learn everything you need to know about game programming. If you're interested in game programming, then this book is exactly what you've been looking for.
Table of Contents (15 chapters)

The anim8 library


We have already set up our player and collider box; the player object is now collidable, but we need to animate it. Earlier on, we already created animation with quad (Chapter 2, LÖving Up!). Now we'll be using a cleaner and straightforward animation library—anim8 (love2D.org/wiki/anim8). Just as with the bump library and ATL, we are also going to require the anim8 library in main.lua; be sure that you have already downloaded a copy of the library for use and make sure anim8.lua is in the same directory with main.lua.

anim8 = require "anim8"
  1. Set the player character sprite, the same one we loaded in Tiled as the player object:

    playerSprite = love.graphics.newImage("maps/sprite.png")
  2. Set up the character's grid and size (playerSprite:getWidth() and playerSprite:getHeight())"

    local a8 = anim8.newGrid(32,32,playerSprite:getWidth(), playerSprite:getHeight())
  3. Now let's define our animation states:

    playerWalkRight = anim8.newAnimation('loop', a8('1-8',1), 0.1)
    playerJumpRight = anim8...