[SOLVED] How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

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
ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

[SOLVED] How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Post by ilovelove2019 »

Hello everyone! I am using the stalker-x camera library to track my characters (I like this library because it has so many character tracking features available). And I have a problem with my mouse, when I use the camera, the shot of the player is no longer accurate (probably because the coordinates of the mouse was wrong). When I disabled the camera everything went back to normal but no one was able to observe my character, the map would be very large later so I needed the camera. I think the problem is that the camera and mouse coordinates are not compatible. To find out more, take a look at my file:

To observe this error, you disable and activate statements 148, 178 and 179 in main.lua at the same time and compare the results. Note, at main.lua 48, 49. I wanted it to be in platform mode but when it crashed I tried to try the screen to screen mode, but not much better. With scr-to-scr, everything seems to be fine at first, but actually when you move the player to the next screen, the error is very obvious. And also note that the shot of the player is starting at row 122 in main.lua.

The main problem is that the player's firing is no longer correct when the camera is turned on. I think I need to do something in the function in row 122. But I'm stupid and incompetent. Please help me.

That is all I have, there are many things still not achieved, I do not want to fail here, please help me and find the answer as soon as possible. I thank you very much and apologize for disturbing your valuable time.
Attachments
thisgameismylife.love
(19.49 KiB) Downloaded 78 times
Last edited by ilovelove2019 on Sat Nov 09, 2019 11:35 pm, edited 1 time in total.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Post by pgimeno »

Every good camera library has functions to convert from screen to world and vice versa. Try this: https://github.com/adnzzzzZ/STALKER-X#u ... dcoordsx-y

If you still have problems after trying that, I'll take a look.
ilovelove2019
Citizen
Posts: 78
Joined: Wed Sep 11, 2019 10:38 am

Re: How is the mouse coordinates in love2d calculated? My problem with camera and mouse.

Post by ilovelove2019 »

Thank you so much!!! :) It work very well, thank you.
Post Reply

Who is online

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