2 registered members (AndrewAMD, juanex),
1,247
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
(*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
OP
Member
|
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:
#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.
|
|
|
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
OP
Member
|
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
|
|
|
|