Page 1 of 1
Collision with Hardon Collider
Posted: Wed Nov 05, 2014 3:34 am
by silvergene
You see, I am terribly new to this kind of stuff, Lua, LÖVE, Hardon Collider.. And I think this is kind of a noob question but..
I can use Hardon Collider to detect the collision, but I don't really know what to do next. I sincerely don't know how to make the character don't go through a wall and simply stand still if there's something blocking the way. I first tried getting the player's coordinates + the enemy/wall coordinates, and doing some stuff with it, but I am certain I messed up somewhere. So, my question is, how?
PS: If there is already any topic about this, sorry about this "repost"
Attaching a .rar file containing the folder:
Re: Collision with Hardon Collider
Posted: Sat Nov 08, 2014 4:22 pm
by silvergene
Nevermind, I think I "technically" did it.
The problem is that the collision is not exact (I sometimes stay a few pixels away from the enemy).
Anyone know a way to fix that?
Re: Collision with Hardon Collider
Posted: Sun Nov 09, 2014 12:37 am
by silvergene
BTW, how do I load sprites into the shapes? :p
Re: Collision with Hardon Collider
Posted: Sun Nov 09, 2014 12:51 am
by davisdude
I've never used it before, but check out the
tutorial. It handles several things, such as collision response (although it was never finished).
Re: Collision with Hardon Collider
Posted: Mon Nov 10, 2014 12:32 am
by silvergene
'Kay, now another quick question (I still wanna know how to add sprites to shapes), how to make melee weapons? I think I am kind of abusing in terms of asking question in a single thread, but seriously, I have no idea.
Re: Collision with Hardon Collider
Posted: Thu Nov 13, 2014 6:13 pm
by guassmith
I don't think you can assign sprites to objects, the fill function of hardoncollider is for debugging purposes. What you can do is load an image, then draw it instead of the shape but simply use the coordinates of the shape for the coordinates of the sprite.
I'm not sure what you did wrong for the collision, but I made some smoother collision detection in the file provided. It works by working out where where the player will move to if an arrow is pressed, then it moves the player shape to that position and checks if it collides with anything. If it collides then the object will go back to the position it was in before it moved, and the player doesn't move. If it doesn't collide then the player moves to that space.
Re: Collision with Hardon Collider
Posted: Wed Nov 19, 2014 1:53 pm
by silvergene
Yea, thanks for the help
Still am a newbie, so I am kind of struggling to understand the code, but I think i got most of it
Now, I tried to make some attack mechanics, but I am having a little trouble.
So, I wanted to kind of.. generalize the attack function, because right now it only works if I add a certain "property" to each of the polygons I create, and having to also call that certain particular "property" on the attack, if you get what I am saying.
The code is kind of a mess, sorrey
If you can help, thanks in advance!
Re: Collision with Hardon Collider
Posted: Wed Nov 19, 2014 7:24 pm
by guassmith
silvergene wrote:Yea, thanks for the help
Still am a newbie, so I am kind of struggling to understand the code, but I think i got most of it
Now, I tried to make some attack mechanics, but I am having a little trouble.
So, I wanted to kind of.. generalize the attack function, because right now it only works if I add a certain "property" to each of the polygons I create, and having to also call that certain particular "property" on the attack, if you get what I am saying.
The code is kind of a mess, sorrey
If you can help, thanks in advance!
I looked at it and modified it a bit, I hope my comments are enough for you to understand what I did. But basically, I really suggest you use tables and loops more when dealing with the enemies, as well as using x:collidesWith(y) instead of the on_collision function.