Page 1 of 1

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

Posted: Wed Dec 08, 2010 1:08 pm
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.

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

Posted: Wed Dec 08, 2010 2:38 pm
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

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

Posted: Wed Dec 08, 2010 4:03 pm
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.

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

Posted: Wed Dec 08, 2010 4:21 pm
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.

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

Posted: Wed Dec 08, 2010 10:01 pm
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