Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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

Moving objects


In our game we would want objects to move, rotate, or just change position. That's the essence of a 2D game. So we are going to move an object across the screen and also are going to rotate it.

Rotating objects

We will create a 10 x 10 square and specify the rotation angle as 0 using the love.graphics.rotate() function; what the code will do is make the object rotate with keyboard actions. The Boolean love.keyboard.isDown() function is used to make keyboard inputs do certain things. Just to cause the object to rotate, we will make the rotation angle increase or decrease in delta time. math.pi is the angular speed, which means that the object will rotate at an angular speed of 180 degrees. Replace the previous code with the next code snippet.

First of all, we can define our variables for the angle, width, and height. A variable is a name or an identifier for a place in the computer's memory where dynamic content is stored; variables store information that will be used later in...

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