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

Bump on it!


This is where we'll configure our collision system using the bump.lua library. bump.lua is a lightweight library that can be found at http://github.com/kikito/bump.lua. Let's edit our previous code and set up the bump. We'll also set up our player to move within the solid world and collide with it. It's a long chunk, so you need to follow the comments to understand what each chunk does!

  1. First of all we require the bump library within main.lua:

    bump = require "bump"
  2. Next, we define our collision callback function bump.collision(), between two objects:

    function bump.collision(obj1, obj2, dx, dy)
  3. Then we define the conditions for a collision between the two objects:

    function bump.shouldCollide(obj1, obj2)
  4. With this, we get an object and return its collision boundary, which is usually a rectangle of parameters l, t, w, and h:

    function bump.getBBox(obj)
       return obj.l, obj.t, obj.w, obj.h
    end

We'll come back and fill the blank spaces between these chunks after we have loaded our solid tiles...

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