Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, SBGuy, Petra), 801 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
noob in need of help #407909
09/21/12 03:49
09/21/12 03:49
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
in this code i have a button that when clicked temporarily moves the mouse position close to the center of the screen for a few seconds and then moves back to the button. can someone explain why it doesn't just stay in the center of the screen? I don't want the mouse cursor to move back to the button

Code:
#include <acknex.h>

BMAP* cursor = "mouse_cursor.png";
BMAP* test_button = "test_button.jpg";

var button_pressed = 0; 

function main()
{
	video_mode = 11;
	video_screen = 1;
	mouse_mode = 3;
	mouse_map = cursor;
	level_load(""); 
	//
	while(1)
	{
		if(key_esc) sys_exit(NULL);
		if(button_pressed == 1) vec_set(mouse_pos,vector(600,500,0));//put the mouse close to the center of screen
		wait(1);
	}		
}

function test()
{
	button_pressed = 1;	
	wait(8);
	button_pressed = 0;
}

PANEL* test_panel =
{ 
   layer = 2; 
   pos_x = 1400; 
   pos_y = 250; 
   size_x = 300; 
   size_y = 800; 
   button(20,20,test_button,test_button,test_button,test,NULL,NULL);
   flags = SHOW;
}


Re: noob in need of help [Re: dd231] #407913
09/21/12 07:33
09/21/12 07:33
Joined: Apr 2008
Posts: 245
GameScore Offline
Member
GameScore  Offline
Member

Joined: Apr 2008
Posts: 245
you set mouse_mode=3;
this will set the mouse_pos to the windows mouse_cursor position
and this is why your mouse jumps back o the "real" mouse position

what we have to do is now to set mouse_mode=1;
next step is to move the mouse_pos of your game with the mouse speed
like this
Code:
mouse_pos.x+=mickey.x*5*time_step;
mouse_pos.y+=mickey.y*5*time_step;



and the rest of your code should look like this


Code:
#include <acknex.h>

BMAP* cursor = "mouse_cursor.png";
BMAP* test_button = "test_button.jpg";

var button_pressed = 0; 

function main()
{
	video_mode = 11;
	video_screen = 1;
	mouse_mode = 1;
	mouse_map = cursor;
	level_load(""); 
	//
	while(1)
	{
		if(key_esc) sys_exit(NULL);
		
		
		mouse_pos.x+=mickey.x*5*time_step;
		mouse_pos.y+=mickey.y*5*time_step;
		
		if(button_pressed == 1)
		{
		vec_set(mouse_pos.x,screen_size.x/2);
	        vec_set(mouse_pos.y,screen_size.y/2);  
                }
		wait(1);
	}		
}

function test()
{
	button_pressed = 1;	
	wait(8);
	button_pressed = 0;
}

PANEL* test_panel =
{ 
   layer = 2; 
   pos_x = 1400; 
   pos_y = 250; 
   size_x = 300; 
   size_y = 800; 
   button(20,20,test_button,test_button,test_button,test,NULL,NULL);
   flags = SHOW;
}


Re: noob in need of help [Re: GameScore] #407943
09/21/12 17:22
09/21/12 17:22
Joined: Jun 2009
Posts: 26
D
dd231 Offline OP
Newbie
dd231  Offline OP
Newbie
D

Joined: Jun 2009
Posts: 26
Brilliant! Thanks so much GameScore for getting back to me and explaining why!!!

Re: noob in need of help [Re: dd231] #407944
09/21/12 17:25
09/21/12 17:25
Joined: Apr 2008
Posts: 245
GameScore Offline
Member
GameScore  Offline
Member

Joined: Apr 2008
Posts: 245
no problem dude


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