Hey. I'm currently trying to make a basic RTS inside of pico 8 but my knowledge of how the mouse input works is a bit lacking. The first thing I tried doing was making it so that when you put the mouse close to the edge of the screen, the camera would pan that direction on the map. The only issue is that the mouse x and y coordinates aren't relative to the camera, and so the boundaries would get left behind as the camera pans away. Another thing I'm stuck on is figuring out how to tell if the mouse is over or clicking on a certain sprite.
Cart included



You need to add the Camera-Position to the Draw-Position, like:
spr(0, mx-1+cx, my-1+cy) |



I’m not sure that’s correct. What 'camera(x,y)' does is exactly to add offsets to drawing functions. To draw something at absolute screen coordinates (UI or HUD), we have to reset the offsets by calling 'camera()'.
For the second question: you can get the map tile that’s at a certain screen position with 'mget'. For sprites drawn by 'spr', you’ll have to iterate through all entities drawn and compare coordinates (search for guides about collision).
[Please log in to post a comment]