Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

Bad guy


We'll define the bad guy's properties; these include his spawn point, direction of motion, and speed of movement.

--the enemy table holds all the parameter we need for the enemy's movement
enemyTable = {}
--length
enemyTable.l=0
--space between the bottom and the ground
enemyTable.t=0
--width
enemyTable.w=32
--height
enemyTable.h=32
--direction
enemyTable.dir=-1
--initial velocity in x direction
enemyTable.vX = 0
--animation state based on direction
enemyTable.animation = EnemyLeft
---set speed and death/life Boolean
local EnemySpeed = 25
local EnemyDied = false
--get the enemy sprite image file
local enemyImage = love.graphics.newImage("maps/wheelie_right.png")

---configure animation for enemy
local a8 = anim8.newGrid(32, 32, enemyImage:getWidth(), enemyImage:getHeight())
local EnemyRight = anim8.newAnimation( a8('1-4',1), 0.9)
local EnemyLeft = anim8.newAnimation(a8('1-4',1),),0.9,nil,true)
---now the EnemySpawn() function, this basically holds the parameters to update the enemy...
lock icon The rest of the chapter is locked
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