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
4 registered members (AndrewAMD, Quad, 7th_zorro, Ayumi), 926 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
a question about mouse movement #285566
08/19/09 04:23
08/19/09 04:23
Joined: Sep 2005
Posts: 508
Texas
not_me Offline OP
User
not_me  Offline OP
User

Joined: Sep 2005
Posts: 508
Texas
I've got a bit of an odd question...and im not sure if its possible, but here goes. Is it possible to restrict the mouses movement to an axis in space(i.e. mouse can only move along the x,y axis in space) is it possible? or is there a way to place a(xy or xz) grid(possibly a model) in space and have the mouse select points on the grid(s)?

[EDIT]: or maybe track the mouses position on a model of a grid...perhaps..

Last edited by not_me; 08/19/09 04:25.

-Initiate Games
-Level designer

http://www.sckratchmagazine.com
Re: a question about mouse movement [Re: not_me] #285583
08/19/09 07:30
08/19/09 07:30
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Code:
mouse_mode = 1 // or 2
while (1) // move it over the screen
{  
mouse_pos.x = mouse_cursor.x;
wait(1);
}


This will lock the mouse to the mouse to the x-axis only.

I just wrote this little snippet which snaps the mouse to a grid. Change the "snap_amount" variable to change the grid size...

Code:
#include <acknex.h>
#include <default.c>

BMAP* arrow = "arrow.pcx";

void main()
{
	
	mouse_map = arrow;
	mouse_mode = 2;
	
	int snap_amount = 25;
	double ux = 0.0;
	double uy = 0.0;
	
	wait(1);
	while (1) // move it over the screen
	{  
		ux = mouse_cursor.x / snap_amount;
		uy = mouse_cursor.y / snap_amount;
		
		mouse_pos.x = (integer(ux)*snap_amount);
		mouse_pos.y = (integer(uy)*snap_amount);
		
		//draw grid
		var i=0; var j=0;
		for(i=0; i<screen_size.x; i+=snap_amount)
		{
			draw_line(vector(i,0,0),vector(255,0,0),100);
			draw_line(vector(i,screen_size.y,0),vector(255,0,0),100);
			draw_line(vector(i,0,0),NULL,100);
		}
		for(j=0; j<screen_size.y; j+=snap_amount)
		{
			draw_line(vector(0,j,0),vector(255,0,0),100);
			draw_line(vector(screen_size.x,j,0),vector(255,0,0),100);
			draw_line(vector(0,j,0),NULL,100);
		}
		wait(1);
	}
}



Snapping to a 3D grid requires a little more thought because you will have to trace from the camera but i think that "mouse_dir3d" will help a lot. I'll have a go and post my results if i can get it to work.

DJB.

Last edited by DJBMASTER; 08/19/09 07:55.
Re: a question about mouse movement [Re: DJBMASTER] #286598
08/26/09 05:33
08/26/09 05:33
Joined: Sep 2005
Posts: 508
Texas
not_me Offline OP
User
not_me  Offline OP
User

Joined: Sep 2005
Posts: 508
Texas
sry for the late response. i havent been able to login to the forums lately...it was kinda wierd, but thankyou for the snippet. You wouldnt happen to know how to make the grid into a 3d grid would you?

Or perhaps display a grid ingame kinda the way the MED 3d viewport does...


-Initiate Games
-Level designer

http://www.sckratchmagazine.com
Re: a question about mouse movement [Re: not_me] #286601
08/26/09 06:36
08/26/09 06:36
Joined: Sep 2005
Posts: 508
Texas
not_me Offline OP
User
not_me  Offline OP
User

Joined: Sep 2005
Posts: 508
Texas
*bump* why is it that whenever i place an object in game space it flies upward infinitely? Im making an rts and whenever an object moves off of a plane that i defined as the level it flies upward infinitely...can anyone explain to me how to counter this?


-Initiate Games
-Level designer

http://www.sckratchmagazine.com

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