Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Nymphodora), 490 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Moving by dragging mouse? #228842
09/22/08 21:36
09/22/08 21:36
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
I am trying to move a model up and down by dragging the mouse up and down, but i cant seem to get it to work, can anyone help?

i tried something similar to this
Code:
action move_model()
{
 while(mouse_left)
 {
   my.z = mouse_pos.z
 }
}

but that didnt do anything

Last edited by Blade28081991; 09/22/08 21:43.

My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: Moving by dragging mouse? [Re: Blade280891] #228863
09/23/08 01:43
09/23/08 01:43
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
Hi

If I'm not wrong there is nothing like mouse_pos.z.
Mouse coordinates are in x and y.
However even with mouse_pos.y there would be problems
because my.z is in world coordinates and mouse_pos.y in
screen coordinates.
So you need to add some sort of conversion formula to
make it move,which can be done with vec_for_screen()
function.

Hope it helps smile







I like good 'views' because they have no 'strings' attached..
Re: Moving by dragging mouse? [Re: zazang] #228868
09/23/08 02:27
09/23/08 02:27
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
I get no errors from using mouse_pos.z

And how would i convert, my future plan is to have the character click something then move it with the mouse.


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: Moving by dragging mouse? [Re: Blade280891] #228989
09/23/08 19:31
09/23/08 19:31
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
any one?


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: Moving by dragging mouse? [Re: Blade280891] #229019
09/23/08 23:59
09/23/08 23:59
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!

I picked up the following code (or something close to it) in this forum a few years back.
I use the mouse to pick an object (my) with the left mouse button
I move it around and when I let go
The enity drops on something or not.

Here the code...you will have to play with this. smile

function pick_drop ()
{
wait (1);
i_counter += 1;
if ((i_counter % 2) == 1)
{
while (mouse_left == 1) //the object is selected with the mouse
{
vec_set (temp_m, vector(mouse_cursor.x,mouse_cursor.y,194)); // play with the z position
vec_for_screen(temp_m, camera);
vec_set (my.x,temp_m.x); // entity and camera are the same
wait (1);
}
}
vec_set (temp_m.x, my.x);
my.z += 10; // (20)

c_move(my,nullvector,nullvector, IGNORE_MAPS| ACTIVATE_TRIGGER | IGNORE_CONTENT | USE_AABB);

if (event_type != EVENT_TRIGGER)
{
my.z -= 10; //
i_counter += 1;
}
}

Hope this is what you wanted.
Ottawa

Re: Moving by dragging mouse? [Re: Ottawa] #229132
09/24/08 18:55
09/24/08 18:55
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
i'd use
Code:
my.z += mickey.y;


Re: Moving by dragging mouse? [Re: MrGuest] #229136
09/24/08 19:09
09/24/08 19:09
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Ok, i tried this
Code:
#include <acknex.h> // include these predefined, needed files in our project
#include <default.c>

ENTITY*box;
function force_power();
function pick_drop();
action forcebox();

function main()
{
	level_load("force_test.wmb");
	wait(1);
	mouse_mode = 4;
	while(1)
	{
		mouse_pos.x = mouse_cursor.x;
	  	mouse_pos.y = mouse_cursor.y;
		wait(1);
	}
}

function pick_drop ()
{
	wait (1);
	i_counter += 1;
	if ((i_counter % 2) == 1)
	{
		while (mouse_left == 1) //the object is selected with the mouse
		{
			vec_set (temp_m, vector(mouse_cursor.x,mouse_cursor.y,194)); // play with the z position
			vec_for_screen(temp_m, camera);
			vec_set (my.x,temp_m.x); // entity and camera are the same
			wait (1);
		}
	}
	vec_set (temp_m.x, my.x);
	my.z += 10; // (20)
	
	c_move(my,nullvector,nullvector, IGNORE_MAPS| ACTIVATE_TRIGGER | IGNORE_CONTENT | USE_AABB);
	
	if (event_type != EVENT_TRIGGER)
	{
		my.z -= 10; //
		i_counter += 1;
	}
}
/*
function force_power()
{
	if (event_type == EVENT_TOUCH)
 	{
		my.ambient = 100; // the make it look bright
	  	my.lightrange = 200; // and generate light on a radius of 200 quants!
	}
	else if(event_type == EVENT_RELEASE)
	{
		my.ambient = 0;
   	my.lightrange = 0;
	}
	if(event_type == EVENT_CLICK)
	{
		while(1)
		{
			if(mouse_left)
			{
				box.z = mouse_pos.z;
				box.x = mouse_cursor.x;
				box.y = mouse_cursor.y;
			//	camera.x = mouse_pos.x;	
			}
		}
	}
}
*/
action forcebox()
{
/*	box = me;
	my.emask |= ENABLE_TOUCH | ENABLE_RELEASE | ENABLE_CLICK;
   // run function highlight_event the wizards are touched or released
   my.event = force_power; 
   */
   if(mouse_left == 1)
   {
		pick_drop();
	}
}


I get errors for undeclared vars, i declared i_counter as an int var, but waht about the temp ones?


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: Moving by dragging mouse? [Re: Blade280891] #229165
09/24/08 23:12
09/24/08 23:12
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi Blade !

Yes, you have to declare all var...
I just provided the code...(that came from the A6 forum
The temp_m var is a temporary variable and should be different for temp

I will look at your code later tonight and get back to you.

Ottawa smile

Re: Moving by dragging mouse? [Re: Ottawa] #229166
09/24/08 23:19
09/24/08 23:19
Joined: Jan 2008
Posts: 1,580
Blade280891 Offline OP
Serious User
Blade280891  Offline OP
Serious User

Joined: Jan 2008
Posts: 1,580
Ok, thanks , i beleive temp_m should be just temp, but im not sure it doesnt seem to work for me frown


My Avatar Randomness V2

"Someone get me to the doctor, and someone call the nurse
And someone buy me roses, and someone burned the church"
Re: Moving by dragging mouse? [Re: Blade280891] #229167
09/24/08 23:25
09/24/08 23:25
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline
User
Ottawa  Offline
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
I changed temp to temp_m to better control my code.
But you can use temp if you want to.

edit :

Notes on your code :
The action for your entity is very important
It must be alive at all times..it may wait or it may do something
but it must be alive...working
in this situation it is processed one time only...and forgotten
You need a repetition somewhere in your code (while(1))
The "my.event" is a good start.

The declaration of the variables
var i_counter = 0; // or integer
VECTOR* temp_m = {x=0;y=0;z=0;}
should help you.

Ottawa wink

Last edited by Ottawa; 09/24/08 23:53. Reason: read code
Page 1 of 2 1 2

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