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.