Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, 1 invisible), 877 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trap the Mouse Cursor? #316063
03/21/10 07:53
03/21/10 07:53
Joined: Jan 2006
Posts: 59
Desert Zone
WolfCoder Offline OP
Junior Member
WolfCoder  Offline OP
Junior Member

Joined: Jan 2006
Posts: 59
Desert Zone
How do you trap the mouse cursor so that the player doesn't have to worry about their mouse leaving the window when they're trying to look around in an first-person game? I would think this is a feature implemented ever since the engine supported windowed mode because, well, some people want to play my first-person game in windowed mode.

Right now if the player turns around enough, the cursor exits the window which is very bad.

I'm using Acknex Commercial 6.60, but since I just started I can update and it won't break my project if this is in an update.

Last edited by WolfCoder; 03/21/10 08:07.
Re: Trap the Mouse Cursor? [Re: WolfCoder] #316082
03/21/10 11:21
03/21/10 11:21
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
It's possible in lite-c with windows.h included:

Originally Posted By: DJBMASTER
#include <acknex.h>
#include <windows.h>

void main()
{
mouse_pointer = 0;
RECT* rect;
GetWindowRect(hWnd,rect);
ClipCursor(rect);
}



"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: Trap the Mouse Cursor? [Re: Superku] #316142
03/21/10 19:12
03/21/10 19:12
Joined: Jan 2006
Posts: 59
Desert Zone
WolfCoder Offline OP
Junior Member
WolfCoder  Offline OP
Junior Member

Joined: Jan 2006
Posts: 59
Desert Zone
What about C-Script?

Re: Trap the Mouse Cursor? [Re: WolfCoder] #316180
03/22/10 08:02
03/22/10 08:02
Joined: Jan 2006
Posts: 59
Desert Zone
WolfCoder Offline OP
Junior Member
WolfCoder  Offline OP
Junior Member

Joined: Jan 2006
Posts: 59
Desert Zone
Oh yeah, and your method is flawed. With your method, the player can still accidentally move or close the window as GetWindowRect returns the rectangle including window border and controls. This is not a good method of trapping the mouse.

Thanks for trying to help, but you shouldn't merely parrot back some solution you saw in another thread without thinking if it really does work. I eventually got it to work with the following plugin function:

Code:
/* Captures the mouse */
DLLFUNC void wcmouse_trap()
{
	RECT rect;
	/* Get the rectangle and see if it is different */
	GetClientRect(ev->hWnd,&rect);
	/* Convert to the screen */
	ClientToScreen(ev->hWnd,(LPPOINT)&rect);
	ClientToScreen(ev->hWnd,(LPPOINT)&rect.right);
	/* Clip the rectangle */
	ClipCursor(&rect);
}



This confines the mouse cursor to the client area and not the entire window area so the user cannot accidentally click on the controls or resize the window.

It's just a matter of using mouse_force to look around.

I have created a plugin+C-Script that, when initialized, traps the mouse cursor with an initial pointer appearance of nothing in windowed mode for as long as the window as focus. If you ALT+TAB or otherwise lose the focus, the mouse is released and taken back when the window regains focus.

Last edited by WolfCoder; 03/22/10 08:28.
Idiot [Re: WolfCoder] #316211
03/22/10 13:36
03/22/10 13:36
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
Oh yeah, and your method is flawed. With your method, the player can still accidentally move or close the window as GetWindowRect returns the rectangle including window border and controls. This is not a good method of trapping the mouse.

Thanks for trying to help, but you shouldn't merely parrot back some solution you saw in another thread without thinking if it really does work.


Oh I'm soooo sorry that I am smart enough to use the search function what you should have done before posting. Now go and celebrate yourself for that plugin.


"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: Idiot [Re: Superku] #316224
03/22/10 15:34
03/22/10 15:34
Joined: Sep 2009
Posts: 496
P
Progger Offline
Senior Member
Progger  Offline
Senior Member
P

Joined: Sep 2009
Posts: 496
try mouse_valid and look what it means in the manual


asking is the best Way to get help laugh laugh laugh
Re: Idiot [Re: rendezvo] #319468
04/15/10 07:13
04/15/10 07:13
Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Cowabanga Offline
Expert
Cowabanga  Offline
Expert

Joined: Aug 2008
Posts: 2,838
take me down to the paradise c...
Quote:
Hello, members,

Goodbye, spammer.

Re: Idiot [Re: Cowabanga] #319493
04/15/10 11:00
04/15/10 11:00
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
@Cowa: wrong tread?


3333333333

Moderated by  HeelX, Spirit 

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