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.
HUMP - yet another set of helpers
- out-of-pixel
- Prole
- Posts: 1
- Joined: Sat Jun 29, 2013 3:55 pm
Re: HUMP - yet another set of helpers
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!
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!
-
- Prole
- Posts: 46
- Joined: Fri May 31, 2013 9:42 pm
Re: HUMP - yet another set of helpers
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:
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).
- 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.
- 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).
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
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:
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.
I suspect that the "gameover" gamestate gets changed to userdata, rather than a table. No idea why.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'
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 170 times
Last edited by Teraku on Tue Sep 09, 2014 8:56 pm, edited 2 times in total.
-
- Party member
- Posts: 712
- Joined: Fri Jun 22, 2012 4:54 pm
- Contact:
Re: HUMP - yet another set of helpers
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
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
- 8bitDaemon
- Prole
- Posts: 5
- Joined: Sat Nov 16, 2013 3:32 am
Re: HUMP - yet another set of helpers
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:
And the inherited class:
I implement in the main file like so :
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
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
}
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;
}
Code: Select all
local Player = require 'Player'
...
...
user = Player(user,256, 256, 10, 1, 100, "knight", 1 )
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: HUMP - yet another set of helpers
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.
- 8bitDaemon
- Prole
- Posts: 5
- Joined: Sat Nov 16, 2013 3:32 am
Re: HUMP - yet another set of helpers
8bitDaemon wrote:My program keeps throwing a "class.lua:62 bad argument #1 to 'ipairs' (table expected, got boolean)
I thought I didRobin wrote:Here's a tip for the future: if you paste in the error traceback, paste in the error message as well.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: HUMP - yet another set of helpers
Sorry, my bad, I was looking at this part:
Read right over the part where you said what the actual error was.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'
Help us help you: attach a .love.
Who is online
Users browsing this forum: No registered users and 1 guest