Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
L÷VE for Lua Game Programming

You're reading from   L÷VE for Lua Game Programming If you want to create 2D games for Windows, Linux, and OS X, this guide to the L?ñVE framework is a must. Written for hobbyists and professionals, it will help you leverage Lua for fast and easy game development.

Arrow left icon
Product type Paperback
Published in Sep 2013
Publisher Packt
ISBN-13 9781782161608
Length 106 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
AKINLAJA DAMILARE JOSHUA AKINLAJA DAMILARE JOSHUA
Author Profile Icon AKINLAJA DAMILARE JOSHUA
AKINLAJA DAMILARE JOSHUA
Arrow right icon
View More author details
Toc

Animation


The animation algorithm will simply play the sprite like a tape of film; we'll be using a basic technique here as LÖve doesn't have an official module for that. Some members of the LÖve forum have come up with different libraries to ease the way we play animations. The use of animation libraries will come up in later chapters. First of all let us load our file:

function love.load()

   sprite = love.graphics.newImage "sprite.png"

end

Then we create quads for each part of the sprite by using love.graphics.newQuad(x, y, width, height, sw, sh), where x is the top-left position of the quad along the x axis, y is the top-left position of the quad along the y axis, width is the width of the quad, height is the height of the quad, sw is the sprite's width, and sh is the sprite's height:

love.graphics.newQuad(0, 0, 32, 32, 256, 32) --- first quad

   love.graphics.newQuad(32, 0, 32, 32, 256, 32) --- second quad

   love.graphics.newQuad(64, 0, 32, 32, 256, 32) --- Third quad

   love.graphics...
You have been reading a chapter from
L÷VE for Lua Game Programming
Published in: Sep 2013
Publisher: Packt
ISBN-13: 9781782161608
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime