Page 10 of 15
Re: HUMP - yet another set of helpers
Posted: Mon Feb 25, 2013 6:19 pm
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.
Re: HUMP - yet another set of helpers
Posted: Sat Jun 29, 2013 4:02 pm
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!
Re: HUMP - yet another set of helpers
Posted: Mon Jul 01, 2013 2:55 am
by RunningGamesStudios
NIce
Re: HUMP - yet another set of helpers
Posted: Thu Aug 22, 2013 4:04 pm
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')
Re: HUMP - yet another set of helpers
Posted: Mon Dec 16, 2013 12:57 pm
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"]
87>
[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.
Re: HUMP - yet another set of helpers
Posted: Mon Dec 16, 2013 4:27 pm
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!
Re: HUMP - yet another set of helpers
Posted: Tue Oct 14, 2014 11:09 pm
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
Re: HUMP - yet another set of helpers
Posted: Wed Oct 15, 2014 6:57 am
by Robin
Here's a tip for the future: if you paste in the error traceback, paste in the error message as well.
Re: HUMP - yet another set of helpers
Posted: Wed Oct 15, 2014 2:07 pm
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
Re: HUMP - yet another set of helpers
Posted: Wed Oct 15, 2014 6:02 pm
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.