Left and Right Collision Detection Help! [FIXED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
TheP3
Citizen
Posts: 62
Joined: Tue Dec 20, 2011 9:20 pm

Left and Right Collision Detection Help! [FIXED]

Post by TheP3 »

So, I really can figure out how to get this darn thing to work. My collision for the top and bottom, are the same for left and right.

In the col.lua it reads a png to see the collision map...

Lots of cool code for spawning mobs and players, so, feel free to use!

Thanks

Nate

edit: I fixed it just added like one pixel padding
Attachments
Game.love
(5.71 KiB) Downloaded 151 times
Last edited by TheP3 on Sun Aug 26, 2012 1:29 am, edited 1 time in total.
I write rules for my computer... I'm not the ruler of the world(yet)... Also, I livestream stuff http://NateAGeek.com/Live
cobrajs
Prole
Posts: 2
Joined: Tue Apr 24, 2012 1:25 am

Re: Left and Right Collision Detection Help! .love file incl

Post by cobrajs »

Which part do you need help with? When I first tried it, it seems that when the player is on the ground they can't move left, but right works fine. I changed the code so that it is

Code: Select all

	if typecol == "left" then
		if ColMap[math.floor(obj1x/32)][math.floor((obj1y + obj1h - 1)/32)] == 1 then
			print("Left")
			return true
		else
			return false
		end
	end
	
	if typecol == "rigth" then
		if ColMap[math.floor((obj1x + obj1w)/32)][math.floor((obj1y + obj1h - 1)/32)] == 1 then
			print("Right")
			return true
		else
			return false
		end
	end
And now left and right movement on the ground works.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests