Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, juanex), 1,247 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19056 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
(*Updated)Using Mouse to Move Object, Rnd Obj Jump??!?? #308271
02/02/10 16:58
02/02/10 16:58
Joined: Sep 2004
Posts: 106
Tn
StOrM Offline OP
Member
StOrM  Offline OP
Member

Joined: Sep 2004
Posts: 106
Tn
Hello,

I am trying to work on some simple object placement code for an editor, and all seems well so far, except for a weird bug causing a quick small jumping bug, where when you click on the arrow attached to the cube so you can click / hold the mouse left button down and drag, you can move the object, but depending on where you click on the arrow at, you get a up / down jumping of the object / to mouse coords:

*EDIT* *NOTE* OK, got the jumping gone, and it works really smooth and fasssst now. But only one problem now, how do I keep the object from flying off screen out into space and / or maybe slow down the moving of the mouse, so as to make the object placement more precise. I am posting the changes to the code below for you to check out, please tell me your ideas, suggestions, and any examples on how to make it better you have.

Thanks

Please see the following code:

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

ENTITY* box;
ENTITY* z_arrow;

// Here is the *NEW and IMPROVED* Function...
function ArrowEvent()
{
	VECTOR temp2;
	var startx;
	var starty;
	var changey;
	
	mouse_calm = 10;
	mouse_time = 16;
	
	if(event_type == EVENT_CLICK)
	{  	
	  startx = mouse_pos.x;
	  starty = mouse_pos.y;
	  
       while(mouse_left == 1) 
		{
					
		if (mouse_pos.y >= starty)
		  {
		  	changey = mouse_pos.y - starty;
		  	if (changey <= 1000)
		  	  {
		  	  	me.z -= changey / 2;
		  	        box.z = me.z - ((box.max_z - box.min_z)/2);
		          }
		     if (changey > 1000)
		       {
		       	me.z -= changey / 2;
		       	box.z = me.z - ((box.max_z - box.min_z)/2);
		       }
		  }
		
		if (mouse_pos.y <= starty)
		  {
		  	changey = starty - mouse_pos.y;
		  	if (changey <= 1000)
		  	  {
		  	     me.z += changey / 2;
		  	     box.z = me.z - ((box.max_z - box.min_z)/2);
		          }
		     if (changey > 1000)
		       {
		       	me.z += changey / 2;
		       	box.z = me.z - ((box.max_z - box.min_z)/2);
		       }
		  }  
		wait(1);
		}
	}
}

action Arrow()
{
	z_arrow= me;
	my.emask = ENABLE_CLICK;
        my.event = ArrowEvent;
}

void main()
{
	mouse_mode = 1;
	level_load(""); 
	ent_createlayer("skycube+6.bmp",SKY|CUBE|SHOW,1);
	mouse_range = 2000;  	
	vec_set(camera.x,vector(-160,-570,30));
	camera.pan = 31;  
	box = ent_create("box.mdl", vector(270,-350,0),NULL);
	z_arrow = ent_create("le_arrow_blue.mdl",vector(0,0,0),Arrow);
	z_arrow.scale_x = 6;
	z_arrow.scale_y = 6;
	z_arrow.scale_z = 6;
	vec_set(z_arrow.x,vector(box.x,box.y,(box.max_z - box.min_z)/2));
	
	while(1)
	{
		mouse_pos.x = mouse_cursor.x;    
		mouse_pos.y = mouse_cursor.y;
		mouse_pos.z = 30;
		wait(1);
	}
}



Thanks for helping me figure out I'm sure either a logic error, or an error in 3DGS, or in my code.

Thanks again!

StOrM

Last edited by StOrM; 02/02/10 20:49.

PKE Pain Is Reality! http://www.pkradio.net/
Re: (*Updated)Using Mouse to Move Object, Rnd Obj Jump??!?? [Re: StOrM] #308386
02/03/10 01:38
02/03/10 01:38
Joined: Sep 2004
Posts: 106
Tn
StOrM Offline OP
Member
StOrM  Offline OP
Member

Joined: Sep 2004
Posts: 106
Tn
No help or ideas on how to fix / improve this code? With all you experienced coders out there, on the forums, I expected a release within minutes, and it has been hours for such a small problem. I have been all through the manual, and different tutorials, looking for a solution, and nothing I have found so far can do what I need, yet I know it can be done, as they had to do it for WED and MED. I am almost tempted to just code the editor in another language with easier to use and understand mouse routines. The manual for 3DGS is lacking in the explanation and examples for mouse handling stuff.

Again any and all help is appreciated, if you could find a few minutes to help out, George, I know your there...

StOrM


PKE Pain Is Reality! http://www.pkradio.net/
Re: (*Updated)Using Mouse to Move Object, Rnd Obj Jump??!?? [Re: StOrM] #308388
02/03/10 02:12
02/03/10 02:12
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
heya, if you haven't already, take a look at mickey.x for horizontal mouse movement, and mickey.y for vertical mouse movement, (mickey.z for scroll wheel if you're using it)

Re: (*Updated)Using Mouse to Move Object, Rnd Obj Jump??!?? [Re: MrGuest] #308726
02/04/10 17:32
02/04/10 17:32
Joined: Sep 2004
Posts: 106
Tn
StOrM Offline OP
Member
StOrM  Offline OP
Member

Joined: Sep 2004
Posts: 106
Tn
Thank you soooo much Mr. Guest! Appreciate it!


PKE Pain Is Reality! http://www.pkradio.net/

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