Page 1 of 1

[SOLVED] Mode 7 + Collision

Posted: Mon Oct 15, 2018 10:23 am
by var77
Hi everyone,

Well I'm back here with a new question. I recently try to make few test with this wonderfull library viewtopic.php?t=83309
that i was looking for in a previews topic. Unfortunatly it seems that it's not handling collision stuff. So i try to add some classic
collision test but seems not working.

Code: Select all

-- collision rectangle
function CheckCollision(x1,y1,w1,h1, x2,y2,w2,h2)
  return x1 < x2+w2 and
         x2 < x1+w1 and
         y1 < y2+h2 and
         y2 < y1+h1
end

--Sprites
	for i,v in ipairs(sprites) do
		PM7.placeSprite(camera,spriteimg,v[1],v[2],0,8,8)	
		
		if CheckCollision(user.x,user.y,user.w,user.h,v[1],v[2],8,8) then
			table.remove(sprites,v)
		end
	end
So if anyone has an idea how to solve this let feel free to share it with us ^^


here is the complete test based on hatninja library:
z.love
(1006.14 KiB) Downloaded 79 times

Re: Mode 7 + Collision

Posted: Mon Oct 15, 2018 12:03 pm
by pgimeno
user.x and user.y contain 400 and 450 respectively, and they don't seem to change. I think you want camera.x and camera.y.

Also, user.h is of no use here, because it's the apparent height in the z direction. If you want the sprite to appear to have a square base, use user.w twice.

Re: Mode 7 + Collision

Posted: Mon Oct 15, 2018 12:37 pm
by var77
And again pgimeno you save my day. With a little step back that seems abvious. My user.x/user.y ain't change and camera.x/camera.y are the changing axis. Thanks again, have a nice day.