Collision with Hardon Collider

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
silvergene
Prole
Posts: 5
Joined: Wed Nov 05, 2014 2:54 am

Collision with Hardon Collider

Post 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:
Attachments
hardonmove.rar
Meh, completely newbie.
(19.62 KiB) Downloaded 181 times
Hey, Listen! Don't be Saria, I didn't mean to Gerudo 'bout it..
User avatar
silvergene
Prole
Posts: 5
Joined: Wed Nov 05, 2014 2:54 am

Re: Collision with Hardon Collider

Post 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?
Attachments
hardonmove.rar
lala
(43.95 KiB) Downloaded 159 times
Hey, Listen! Don't be Saria, I didn't mean to Gerudo 'bout it..
User avatar
silvergene
Prole
Posts: 5
Joined: Wed Nov 05, 2014 2:54 am

Re: Collision with Hardon Collider

Post by silvergene »

BTW, how do I load sprites into the shapes? :p
Hey, Listen! Don't be Saria, I didn't mean to Gerudo 'bout it..
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Collision with Hardon Collider

Post 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).
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
silvergene
Prole
Posts: 5
Joined: Wed Nov 05, 2014 2:54 am

Re: Collision with Hardon Collider

Post 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.
Hey, Listen! Don't be Saria, I didn't mean to Gerudo 'bout it..
guassmith
Prole
Posts: 5
Joined: Sat Oct 11, 2014 3:42 pm

Re: Collision with Hardon Collider

Post 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.
Attachments
hardonmove_fixed.rar
(47.06 KiB) Downloaded 156 times
User avatar
silvergene
Prole
Posts: 5
Joined: Wed Nov 05, 2014 2:54 am

Re: Collision with Hardon Collider

Post by silvergene »

Yea, thanks for the help :awesome:

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!
Attachments
hardonmove1.love
(297.09 KiB) Downloaded 165 times
Hey, Listen! Don't be Saria, I didn't mean to Gerudo 'bout it..
guassmith
Prole
Posts: 5
Joined: Sat Oct 11, 2014 3:42 pm

Re: Collision with Hardon Collider

Post by guassmith »

silvergene wrote:Yea, thanks for the help :awesome:

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.
Attachments
hardonmove1_fixed.love
(297.23 KiB) Downloaded 192 times
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests