HUMP - yet another set of helpers

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

HUMP - yet another set of helpers

Post by vrld »

There are quite a number of helper libraries out there, ranging from vector classes to complete frameworks like Pölygamy, but I decided to release the byproducts of projects anyway.

And thus hump - LÖVE Helper Utilities for Massive Progression - was born.
Currently it features a matured vector class, a simple and easy class system, a gamestate system, timers and tweens, signals and slots, and a camera with locking and movement smoothing
I may add other things like some time in the future.

Hump differs from other libraries in that every component is independent of the remaining ones (well, apart from camera.lua, which needs the vector class), meaning that you can pick and choose what you need and what you don't. Hump's footprint is very small and it should fit nicely into your projects.

Sourcecode and documentation are available on github and readthedocs:

Documentation: http://hump.readthedocs.org
Sourcecode: http://github.com/vrld/hump
Last edited by vrld on Mon Oct 12, 2015 6:36 am, edited 2 times in total.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: HUMP - yet another set of helpers

Post by nevon »

Nice! That's great, and I will most likely use this in upcoming projects. What license is it under?
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: HUMP - yet another set of helpers

Post by vrld »

I knew i forgot something, so, ahem:
Helper Utilities for a Multitude of Problems is free software under the (modified) MIT license. Do whatever you want with it :D
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Chief
Party member
Posts: 101
Joined: Fri Mar 12, 2010 7:57 am
Location: Norway, 67° north

Re: HUMP - yet another set of helpers

Post by Chief »

Lövely! Gotta love the open source!
Last edited by Chief on Sat Jun 04, 2011 9:11 pm, edited 1 time in total.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: HUMP - yet another set of helpers

Post by nevon »

So, I wanted to use the gamestate lib and the class lib. The documentation for the class one is great, but there isn't any for the other one. It seems straightforward enough for the most part; the only thing I'm wondering about is how to use the enter and leave states. Got an example to show?
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: HUMP - yet another set of helpers

Post by vrld »

The enter and leave functions are called when you use Gamestate.switch(to, ...).

The first argument to the enter function is the previous state, the rest are the remaining arguments passed to Gamestate.switch. The previous-state-as-argument mostly a hack to retrieve state values not passed to Gamestate.switch but also to make the switch call not too verbose.

The leave is called right before the state is switched (and before the enter of the next state). I mostly use this for stopping music or resetting fonts.

An example:

Code: Select all

Gamestate.titlescreen = Gamestate.new()
local st = Gamestate.titlescreen

function st:enter()
    start_music()
    love.graphics.setBackgroundColor(10,20,30)
    love.graphics.setColor(0,0,0)
end

function st:leave()
    stop_music()
end

function st:keyreleased(key)
    if key == 'return' then
        Gamestate.switch(Gamestate.game, self.playerName)
    end
end

[...]

Gamestate.game = Gamestate.new()
local st = Gamestate.game

function st:enter(pre, playerName)
    if pre == Gamestate.pause then return end
    self.playerName = playerName
end
[...]
For a working example see here: http://github.com/vrld/notalone/tree/master/state/
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: HUMP - yet another set of helpers

Post by nevon »

I'm using the gamestate lib now, and it is incredibly easy to use. Thanks a bunch for making and releasing this.
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: HUMP - yet another set of helpers

Post by pekka »

Good job with the documentation, vrld. You're being a model to all library makers here.

There's a cosmetic mark-up problem after function Gamestate.mousereleased(x,y,btn) that you might want to correct some time.
User avatar
Sslaxx
Citizen
Posts: 57
Joined: Sat Feb 14, 2009 8:54 pm
Location: Malvern, Worcs, UK
Contact:

Re: HUMP - yet another set of helpers

Post by Sslaxx »

I'm doing something pretty wrong with the gamestate code, I just don't know what.

http://sslaxx.twu.net/EggTester.love - just started to convert one section of the code so far to use gamestates, but it produces this error:
boot [string "Code/gamestate.lua"]:28: attempt to index field 'current' (a nil value) stack traceback:
[string "boot.lua"]:833: in function 'error_printer'
[string "boot.lua"]:768: in function <[string "boot.lua"]:766>
[string "Code/gamestate.lua"]:28: in function 'update'
[string "boot.lua"]:307: in function <[string "boot.lua"]:295>
[C]: in function 'xpcall'
[string "boot.lua"]:840: in main chunk
Help?
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: HUMP - yet another set of helpers

Post by vrld »

pekka wrote:There's a cosmetic mark-up problem after function Gamestate.mousereleased(x,y,btn) that you might want to correct some time.
Thanks, I missed that.
I've created a git project page with a more usable documentation: http://vrld.github.com/hump/
Sslaxx wrote:Help?
That error occurs because you did not use Gamestate.switch() to enter your title gamestate.
Rather than calling Gamestate.TitleScreen:enter() you need to do Gamestate.switch(Gamestate.TitleScreen) - preferably in love.load() so you can be sure the state exists.
I pointed that out in the new documentation and also added a dummy initial state to gamestate.lua which will throw errors at you if did not switch to a valid state.
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests