LÖVE-class - LÖVE objects as classes

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

LÖVE-class - LÖVE objects as classes

Post by thelinx »

Do you wish LÖVE had a more class-oriented approach? LÖVE-class is your friend!

Features
  • 2D Vector class with vector math built-in.
  • Circle class with collision detection.
  • Color class for easy re-use of colours.
  • SoundEffect class with built-in source management.
  • String library extensions.
  • Wraps most LÖVE objects:
    • Image
    • ParticleSystem
    • Framebuffer
    • Font
    • ImageFont
    • Quad
    • Music
Example

Code: Select all

-- before:
myImage = love.graphics.newImage("image.png")
print(myImage:getWidth())
love.graphics.draw(myImage, 50, 10)
-- after:
myImage = Image("image.png") -- or just Image "image.png" - Lua is cool like that.
print(myImage:getWidth()) -- the object's functions still work without a hitch!
myImage:draw(50, 10) -- and you can pass all the other love.graphics.draw arguments to this function as well!
Dependencies
LÖVE-class requires MiddleClass and MiddleClass-Extras.

Including in your game
If your game folder is a Git repo, including the latest version of LÖVE-class is easy as cake.

Code: Select all

git submodule add git://github.com/TheLinx/loveclass.git lib/loveclass # or wherever else you want the LÖVE-class folder.
Then, just require lib.loveclass.
You can also download the latest sources from GitHub.
LÖVE-class uses the BSD license, which means you can use it freely in your game as long as you keep the license file in the loveclass folder.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: LÖVE-class - LÖVE objects as classes

Post by TechnoCat »

Some things I notice with the Vector class.
There are no 3d vectors.
They are missing cross product.

Also, why is stateful required? https://github.com/TheLinx/loveclass/bl ... nit.lua#L2
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: LÖVE-class - LÖVE objects as classes

Post by thelinx »

TechnoCat wrote:Some things I notice with the Vector class.
There are no 3d vectors.
They are missing cross product.
I didn't make 3D vectors because LÖVE is a 2D engine.
TechnoCat wrote: Also, why is stateful required? https://github.com/TheLinx/loveclass/bl ... nit.lua#L2
Fixed, thanks.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: LÖVE-class - LÖVE objects as classes

Post by TechnoCat »

thelinx wrote:
TechnoCat wrote:Some things I notice with the Vector class.
There are no 3d vectors.
They are missing cross product.
I didn't make 3D vectors because LÖVE is a 2D engine.
Well, that doesn't mean 2d games don't use the z-axis sometimes.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: LÖVE-class - LÖVE objects as classes

Post by zac352 »

TechnoCat wrote:
thelinx wrote:
TechnoCat wrote:Some things I notice with the Vector class.
There are no 3d vectors.
They are missing cross product.
I didn't make 3D vectors because LÖVE is a 2D engine.
Well, that doesn't mean 2d games don't use the z-axis sometimes.
Especially when you start doing isometrics. :p
Hello, I am not dead.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests