Changing to Collision?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 4
- Joined: Wed Jan 25, 2012 5:59 pm
- Location: United Kingdom
Changing to Collision?
This is my first time using love2D and Lua and I've kinda went through a workaround for the collision with ground, and I've got no idea how to add collision now.
I honestly don't understand the ground and collision things because my friend helped me do all that but he doesn't how to make a fully working collision onto my ground either.
This was just a little test for me to use with Lua, and I've been adding since.
Anybody up for helping me out?
I honestly don't understand the ground and collision things because my friend helped me do all that but he doesn't how to make a fully working collision onto my ground either.
This was just a little test for me to use with Lua, and I've been adding since.
Anybody up for helping me out?
- Attachments
-
- test.love
- A simple test, all the backgrounds and stuff were merely used off google images to rush the code for now, but I can get them done later in Photoshop.
- (1.6 MiB) Downloaded 147 times
- baconhawka7x
- Party member
- Posts: 494
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Changing to Collision?
I don't understand what you are asking, it looks like your collision works just fine.
-
- Prole
- Posts: 4
- Joined: Wed Jan 25, 2012 5:59 pm
- Location: United Kingdom
Re: Changing to Collision?
I mean if I were to add walls, or anything else, all i've added is a floor, and my player isn't colliding to it.
- baconhawka7x
- Party member
- Posts: 494
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Changing to Collision?
I suggest checking out bounding box collision(https://love2d.org/wiki/BoundingBox.lua) if you haven't already. But basically you want to get the x and y of the player(Which I'm pretty sure you have already), which are in the top left corner of the picture. Then get all three other corners, do the same for a wall, and then do something like
But also include the y positions too. The only downside to bounding box is the "box" part:p
Code: Select all
if heroCornerLeft.x < wallCornerRight.x then
herocornerLeft.x = wallCornerRight.x
end
-
- Prole
- Posts: 4
- Joined: Wed Jan 25, 2012 5:59 pm
- Location: United Kingdom
Re: Changing to Collision?
Where would this go?baconhawka7x wrote:I suggest checking out bounding box collision(https://love2d.org/wiki/BoundingBox.lua) if you haven't already. But basically you want to get the x and y of the player(Which I'm pretty sure you have already), which are in the top left corner of the picture. Then get all three other corners, do the same for a wall, and then do something like
But also include the y positions too. The only downside to bounding box is the "box" part:pCode: Select all
if heroCornerLeft.x < wallCornerRight.x then herocornerLeft.x = wallCornerRight.x end
in:
Code: Select all
function CheckCollision(ax1,ay1,aw,ah, bx1,by1,bw,bh)
Re: Changing to Collision?
He was giving an example on how you resolve the collision. You have to think of collision in two parts: detection and resolution. In other words, first you find out if you have a collision and then you do something about it. In your case you want to move the player out of the floor/wall/whatever.
That CheckCollision function is only the detection part.
That CheckCollision function is only the detection part.
- baconhawka7x
- Party member
- Posts: 494
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Changing to Collision?
Exactly, just do something likeKadoba wrote:He was giving an example on how you resolve the collision. You have to think of collision in two parts: detection and resolution. In other words, first you find out if you have a collision and then you do something about it. In your case you want to move the player out of the floor/wall/whatever.
That CheckCollision function is only the detection part.
Code: Select all
is_collided = false
- baconhawka7x
- Party member
- Posts: 494
- Joined: Mon Nov 21, 2011 7:05 am
- Location: Oregon, USA
- Contact:
Re: Changing to Collision?
Exactly, just do something likeKadoba wrote:He was giving an example on how you resolve the collision. You have to think of collision in two parts: detection and resolution. In other words, first you find out if you have a collision and then you do something about it. In your case you want to move the player out of the floor/wall/whatever.
That CheckCollision function is only the detection part.
Code: Select all
is_collided = false
-
- Prole
- Posts: 4
- Joined: Wed Jan 25, 2012 5:59 pm
- Location: United Kingdom
Re: Changing to Collision?
I seem to be still having a problem with collision because the tutorial is using solid objects, I'm using images - http://pastebin.com/QrWkuxwc
Still quite new with lua ;?
Still quite new with lua ;?
Re: Changing to Collision?
What do you mean by solid objects?
Your collision system right now is just basically not letting the player go below a certain point so it appears you have a floor.
Your collision system right now is just basically not letting the player go below a certain point so it appears you have a floor.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Bing [Bot] and 11 guests