Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Ayumi, 1 invisible), 584 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Lock the mouse pointer inside the game window? #415453
01/18/13 20:10
01/18/13 20:10
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
Hello !

I have a question about the game window and mouse cursor related to windowed mode of the game window.

In my platform game, i let the player use mouse for his movement.
The problem is that when you move the mouse , the mouse cursors gets out the game window ...And when the player clicks out the window for an action ingame, the game window is brought behind the window that is clicked on.(which is normal you 'd say).

I am looking for a way to lock the mouse pointer inside the game window and not let the mouse pointer click out of the game window.

I have searched the manual of course, but no result.
And online tutorial.

I know that fullscreen would avoid that problem, but i want a solution for windowed screen.
And i dont seem to find it ...

Re: Lock the mouse pointer inside the game window? [Re: Mo222] #415485
01/19/13 14:13
01/19/13 14:13
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You cannot and - more importantly - SHOULD not restrict the mouse movement to a certain window. If the player is choosing windowed mode he does so for a reason and you'd take just this reason away with the restriction.

To your problem: on every mouse click check if the mouse is within the bounds of the window. If it is not just ignore the click. You can use http://www.conitec.net/beta/amouse_valid.htm for this purpose.


Always learn from history, to be sure you make the same mistakes again...
Re: Lock the mouse pointer inside the game window? [Re: Uhrwerk] #415487
01/19/13 14:37
01/19/13 14:37
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I have to disagree with Uhrwerk here: Locking the mouse is perfectly fine and necessary for most games where the mouse is used to handle more than just a menu. However, the mouse should unlock when the engine window loses focus (f.i. by pressing Alt+Tab) or maybe even when the player presses Esc and opens the menu. You can add an option in the options menu of your game where the player can disable the mouse locking, too (that's how Starcraft II does it).

It is easily possible with lite-C to restrict the mouse pointer to the engine window but I fear it's not so easy with C-Script, I assume you have to use a DLL and I don't know if such a DLL exists.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Lock the mouse pointer inside the game window? [Re: Superku] #415514
01/19/13 19:12
01/19/13 19:12
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Originally Posted By: Superku
However, the mouse should unlock when the engine window loses focus

That's exactly the point for me. Many people do not know how to change the currently focused window, besides clicking another one.


Always learn from history, to be sure you make the same mistakes again...
Re: Lock the mouse pointer inside the game window? [Re: Uhrwerk] #415520
01/19/13 20:03
01/19/13 20:03
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Just use SetCursorPos API...
If the window isnt in ForeGround then dont set mouse pos. Not that hard?
Wheres the problem here?

Re: Lock the mouse pointer inside the game window? [Re: Ch40zzC0d3r] #415523
01/19/13 20:16
01/19/13 20:16
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
i think it's C-Script...


Visit my site: www.masterq32.de

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1