How to convert mouse position to relative coords

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
InTheProcess
Prole
Posts: 11
Joined: Thu May 27, 2021 4:19 pm

How to convert mouse position to relative coords

Post by InTheProcess »

I am making a game that uses an isometric perspective. I have a formula that converts the tiles' actual positions to the relative coords. It doesn't seem to work the same with my mouse. The formula is below:

Code: Select all

	local a,b,c,d = x*0.5*w, -y*0.5*h, x*0.25*w, y*0.25*h
	local matrix = {d, -b, -c, a}
	--Using the inverse of the matrix
	for i,v in ipairs(matrix) do
		matrix[i] = (1/(a*d-b*c))*v
	end
User avatar
dusoft
Party member
Posts: 655
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: How to convert mouse position to relative coords

Post by dusoft »

Try to use some cam system / library, so you don't have to create calculations yourself.
https://github.com/love2d-community/awe ... e2d#camera
User avatar
marclurr
Party member
Posts: 158
Joined: Fri Apr 22, 2022 9:25 am

Re: How to convert mouse position to relative coords

Post by marclurr »

There's a nice video by javidx9 channel that shows how to do this. https://www.youtube.com/watch?v=ukkbNKTgf5U&t=1s
Post Reply

Who is online

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