Log In  


Hey all,

So what I'm trying to do is this... I've used a rotary spinner controller that reads as a mouse axis on other platforms before (Unity). I can get the 'velocity' of the spinner controller by reading the difference in mouse X values between frames. I enabled mouse support on PICO-8 to try a similar thing with PICO (a rotary spinner PICO-8 game! How cool would that be, right?); however, I noticed the mouse position no longer updates beyond the end of the screen, which is somewhat expected. In fact, I don't know why it works on Unity/Windows. This means the 'spinner' has a definite start and stop and I can't spin the spinner indefinitely and continue to measure its virtual velocity in this way.

Is there a way.... to 'write' a new mouse position so I can have the mouse 'wrap' around the edge of the screen? I know this is sort of an.... off the wall issue to be having but any thoughts are appreciated!

Nick



1

Yes it is possible, but it's a bit awkward. The thing is you'd be trapping the cursor into the pico-8 window anyway, so you might as well lock the pointer (flag 0x4 when enabling the mouse). After doing that, you can read the relative mouse movement rather than the raw position. The problem is that it's in desktop resolution rather than pico-8's resolution, and I'm not aware of any way to determine the current scaling level that pico-8 is using. Basically you have to guess how much movement equates to 1 pixel's worth and divide the movement by that amount.

If that's not a problem for your use, then you can simulate the mouse by just keeping a pair of variables around that keeps track of the theoretical mouse position, update them each frame with the relative movement (stat(38) and stat(39)) then draw a sprite at the cursor position with offsets for whatever part of your cursor sprite makes the most sense as the dot. The simplest way to have the cursor wrap is to use code like this after updating the cursor position:

mouse_x%=128
mouse_y%=128

(assuming you're using pixel coordinates of course)


1

Hi @ROBYSOFT:

To go in line with what @kimiyoribaka said, there is only one way to do what you want, and unfortunately, it will not work online.

However, it does work offline. Try this out.

Cart #wrarmo-0 | 2022-10-24 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Run that offline. It should appear in SPLORE if you don't want to manually load the name via:

load #wrarmo

Now move the mouse around and see it never moves off the edge and does indeed wrap around infinitely.

However this cannot be done online.


Thank you so much @kimiyoribaka and @dw817! This community never fails to amaze me. I'll post back to this thread when I have my project further along, I think you'll get a kick out of it -



[Please log in to post a comment]