[SOLVED] Mode 7 + Collision

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
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

[SOLVED] Mode 7 + Collision

Post 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 73 times
Last edited by var77 on Mon Oct 15, 2018 12:37 pm, edited 1 time in total.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Mode 7 + Collision

Post 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.
User avatar
var77
Citizen
Posts: 52
Joined: Wed May 02, 2018 1:57 pm

Re: Mode 7 + Collision

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 49 guests