HUMP - yet another set of helpers

Showcase your libraries, tools and other projects that help your fellow love users.
Frohman
Prole
Posts: 21
Joined: Sat Dec 08, 2012 12:32 pm

Re: HUMP - yet another set of helpers

Post by Frohman »

Great to hear about that update, I'll check right away!
Yeah, looks fine on this end with LUBE.

I'm new to Lua and even newer to classes in Lua, so this is all kind of different to me - as far as I can tell, after
universe[uid] = LocalPlayer(uid, vector(x,y))
universe[uid] is a table, but it has no fields (so if I try to access universe[uid].pos, I'm told it is nil)
I haven't done any testing with this yet, it may be related to the LocalPlayer being a child of Player, and Player's fields (including pos, as you can see in my code) might be the ones not being initialised.
User avatar
out-of-pixel
Prole
Posts: 1
Joined: Sat Jun 29, 2013 3:55 pm

Re: HUMP - yet another set of helpers

Post by out-of-pixel »

Hello vrld,

first i want to thank you for your library, it's awesome.
I add a function to your vector.lua which returns the rotation between a vector and the normal sprite alignment.
Check it out on GitHub.
Hope you like it.

Ah, and i want to say hello, by the way.
Löve is amazing!
RunningGamesStudios
Prole
Posts: 46
Joined: Fri May 31, 2013 9:42 pm

Re: HUMP - yet another set of helpers

Post by RunningGamesStudios »

NIce
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 »

Right in time before LD27: Updates!

Well, actually some of the changes are quite old, but I never came around to document and announce them. Anyway, here goes:

hump.vector and hump.vector-light:
  • Added vector.trim() to trim a vector to a maximum length (courtesy of ricardozanini).
  • Added vector.angleTo() to calculate the angle between two vectors (courtesy of out-of-pixel).
  • Added vector-light.dist2() and vector.dist2() to calculate squared distance of two vectors (courtesy of superquadratic, appropriately enough).
hump.gamestate
  • Added gamestate.current() to get the currently active gamestate object.
  • Added gamestate.push() and gamestate.pop() to implement gamestate stacks. Super useful for pause screens and convoluted menus. See the documentation for more info, as usual.
hump.timer
  • Fixed a bug where canceling of periodic timers did not work.
  • Added timer.tween(), a tweening library with a twist: you can define your own tweening method without too much effort. Again the documentation has more information (and pretty graphs too).
The tweening library also works a bit different than other libraries in that it allows you to stack multiple tweens on the same variable on top of each other. So this will have some interesting effects:

Code: Select all

circle = {x = 0, y = 0, radius = 100}
-- superimpose two tweens: the end position will be x = 90
Timer.tween(5, circle, {x = 100}, 'in-out-quad')
Timer.tween(1, circle, {x = -10}, 'linear')

-- those two cancel each other out
Timer.tween(5, circle, {y = 100}, 'bounce')
Timer.tween(5, circle, {y = -100}, 'bounce')
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
Teraku
Prole
Posts: 27
Joined: Mon Jun 24, 2013 10:01 am
Location: The Netherlands

Re: HUMP - yet another set of helpers

Post by Teraku »

I seem to have a problem when switching between gamestates multiple times. I have two gamestates at the moment, spacegame and gameover. I want the player to be able to restart after a game over. This is working at the moment. However, when the player goes game over a second time, I get this error:
Error: hump/gamestate.lua:42: attempt to index local 'to' (a userdata value)
stack traceback:
hump/gamestate.lua:42: in function 'switch'
main.lua:40: in function 'gameOver'
combat.lua:26: in function 'playerDie'
spacegame.lua:343: in function <spacegame.lua:324>
[string "boot.lua"]:412: in function <[string "boot.lua"]:387>
[C]: in function 'xpcall'
I suspect that the "gameover" gamestate gets changed to userdata, rather than a table. No idea why.

Help would be really appreciated. I've attached a .love file of my game. You can press O to quickly get a game over, for simplicity's sake. Once you get a game over, press Z to re-enter the game.

EDIT: I managed to fix this by dynamically loading gamestates into memory, and then completely wiping the "spacegame" gamestate once I get a game over. Not very elegant, but I was forced to do this due to lack of support on the developer's part.
Attachments
Herbert.love
(3.47 MiB) Downloaded 171 times
Last edited by Teraku on Tue Sep 09, 2014 8:56 pm, edited 2 times in total.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: HUMP - yet another set of helpers

Post by Germanunkol »

I was just about to check if this supports 0.9.0 already, then I see your commit on github which adds 0.9.0 support. Awesome, thanks!
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
8bitDaemon
Prole
Posts: 5
Joined: Sat Nov 16, 2013 3:32 am

Re: HUMP - yet another set of helpers

Post by 8bitDaemon »

What's goin on guys? I'm having a bit of an error with the hump.class implementation. My program keeps throwing a "class.lua:62 bad argument #1 to 'ipairs' (table expected, got boolean)

Here is the code for the two classes I was making:

Code: Select all

Class = require 'class'
Actor = Class{
	init = function(self, gridx, gridy, mspeed, ap, speed)
	self.gridx = gridx
	self.gridy = gridy
	self.mspeed = mspeed
	self.ap = ap
	self.speed = speed
	end
}
And the inherited class:

Code: Select all

Class = require 'class'
Actor = require 'Actor'

Player = Class{
__includes = Actor,
init = function(self,gridx, gridy, mspeed, ap, speed, chrClass, level )
Actor.init(self, gridx, gridy, mspeed, ap, speed)
self.chrClass = chrClass
self.level = level
end;
__upLeft = function(self)
	self.gridy = self.gridy-32
	self.gridx = self.gridx -32
	end;
__up = function(self)
		self.gridy = self.gridy - 32
	end;
__upRight = function(self)
		self.gridy = self.gridy -32
		self.gridx = self.gridx +32
	end;
__right = function(self)
		self.gridx = self.gridx +32
	end;
__downRight = function(self)
	self.gridx = self.gridx+32
	self.gridy = self.gridy + 32
	end;
__down = function(self)
	self.gridy = self.gridy +32
	end;
__downLeft = function(self)
	player.gridx = player.gridx-32
	player.gridy = player.gridy + 32
	end;
__left = function(self)
		player.gridx = player.gridx-32
	end;


}
I implement in the main file like so :

Code: Select all

local Player = require 'Player'
...
...
	user = Player(user,256, 256, 10, 1, 100, "knight", 1 )
Is there something I missed in implementing hump?

The complete error traceback:
[C]: in function 'ipairs'
class.lua:62 in function 'Class'
Player.lua:4 in main chunk
[C] in function 'require'
[C]: in function 'require'
[C]: in function 'xpcall'

Edit: I figured it out! It had to do with local variables messing eachother up and the actual files not having a return at the end!
I figured out the solution from here : viewtopic.php?f=4&t=17740&p=81894&hilit ... ass#p81894
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: HUMP - yet another set of helpers

Post by Robin »

Here's a tip for the future: if you paste in the error traceback, paste in the error message as well. :)
Help us help you: attach a .love.
User avatar
8bitDaemon
Prole
Posts: 5
Joined: Sat Nov 16, 2013 3:32 am

Re: HUMP - yet another set of helpers

Post by 8bitDaemon »

8bitDaemon wrote:My program keeps throwing a "class.lua:62 bad argument #1 to 'ipairs' (table expected, got boolean)
Robin wrote:Here's a tip for the future: if you paste in the error traceback, paste in the error message as well. :)
I thought I did :shock:
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: HUMP - yet another set of helpers

Post by Robin »

Sorry, my bad, I was looking at this part:
8bitDaemon wrote: The complete error traceback:
[C]: in function 'ipairs'
class.lua:62 in function 'Class'
Player.lua:4 in main chunk
[C] in function 'require'
[C]: in function 'require'
[C]: in function 'xpcall'
Read right over the part where you said what the actual error was.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests