[RESOLVED] Strange behavior, works on Windows but not on the Web

Started by Joacim Andersson, Sun 26/01/2025 18:20:24

Previous topic - Next topic

Joacim Andersson

I have a mini puzzle game within my game that works perfectly in the editor or compiled for Windows but acts very weirdly when compiled for the Web.

I can't explain why, I have created a minimum version that only has the mini puzzle game and uploaded the source to:
https://brixoft.itch.io/unblockme

Password: UnblockMe

Can any of you AGS experts help me understand why this code doesn't work on the web?

Crimson Wizard

Could you at least tell which part does not work properly, what to look for?

Joacim Andersson

Well, the game doesn't work. You drag blocks around but on the web they can jump on top of each other. A block that only should be possible to drag and drop in the horizontal direction can jump down or up in the vertical direction. None of that happens when I run it in the editor, or as a compiled EXE file.

eri0o

Are you doing this by restricting mouse position? This doesn't work in the web - imagine a website captures your mouse and forced it to click in something you don't want.

Crimson Wizard

#4
I can see mouse.SetPosition calls in the script, maybe that does not work?

Joacim Andersson

Yes, I'm using mouse.SetPosition to move the mouse to the same X and Y position of the button you've started to drag. This was done for pure laziness on my part so I didn't have to calculate the new position of the button as you start to drag it.

Now that you point it out I see that this is obviously what causes this erroneous behavior.

Now comes the tedious part which requires a recompile just to test the slightest change.

Thank you both so much.

eri0o

There is a way to use SetPosition of sorts, in the web, the website has to be fullscreen and then you have to set relative mode in the mouse, then you can use SetPosition, but it doesn't work in mobile, and I think it doesn't work in Safari either - or it has some bug there. If the user exits fullscreen - by using either Esc or any other way, then it will also unlock the mouse.

Overall I really recommend not relying on it for the web. I tried some hacks because I really wanted to use it - I use it to fake infinite mouse mode for my FPS games. But it seems the browser really have this with a ton of issues since they really want to protect the user from an evil website that could force you to click something.

Joacim Andersson

Quote from: eri0o on Sun 26/01/2025 20:41:10There is a way to use SetPosition of sorts, in the web, the website has to be fullscreen and then you have to set relative mode in the mouse
I rewrote the code so it doesn't use SetPosition, which I should have done, to begin with, I was just lazy. Anyway, now it works, kind of, it still acts a little bit strange on the web, but it's a tiny thing that I don't care about.

SMF spam blocked by CleanTalk