Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (Akow), 1,403 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
mouse coordinates #277069
07/07/09 15:46
07/07/09 15:46
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
The question is: how can I make the cursor appear in the center of the screen after loading the level, so that its new central coordinates become the initial position of the mouse? And how can I make limits for the cursor movement on the screen?
Maybe I've explained my problem a bit confusingly, so a would mention the Counter-Strike game to clarify it:
When I launch the game I can move cursor anywhere I want...

when I start a new level my cursor stands on its place if I don't move it with my mouse....

But when the level is loaded the cursor goes to its new position in the center of the window, and when I move the mouse the cursor starts its movement from its new location....

Thank you in advance.

Last edited by BastovBros; 07/07/09 15:47.

a generator of dull questions smile
Re: mouse coordinates [Re: BastovBros] #277071
07/07/09 15:57
07/07/09 15:57
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
vec_set(mouse_cursor, vector(0,0,0));
vec_set(mouse_pos, mouse_cursor);

o.O this?


Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: mouse coordinates [Re: Espér] #277072
07/07/09 16:13
07/07/09 16:13
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
Thanks,
emmm... almost, but how to make the cursor movable then? it's placed in the 0,0,0 position and stands there all the time...

Last edited by BastovBros; 07/07/09 16:13.

a generator of dull questions smile
Re: mouse coordinates [Re: BastovBros] #277074
07/07/09 16:20
07/07/09 16:20
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
if you call it in a while loop, this is not working ^^

my idea:
Code:
var setcursor = 1;

...

while(1)
{
  if(setcursor == 1)
  {
    vec_set(mouse_cursor, vector(0,0,0));
    vec_set(mouse_pos, mouse_cursor);
    setcursor = 0;
  }  
  else
  {
    vec_set(mouse_pos, mouse_cursor);
  }
  wait(1);
}


(not tested)

just set setcursor to 1 for centering the mouse.

Last edited by Espér; 07/07/09 16:21.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: mouse coordinates [Re: Espér] #277075
07/07/09 16:25
07/07/09 16:25
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
he-he, its almost the same as my yesterday's question smile
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=276885#Post276885


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: mouse coordinates [Re: VeT] #277089
07/07/09 18:00
07/07/09 18:00
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
>to Vet
lol, you should have written the solution to your question so that I figure out the solution to mine. Maybe I would not create my thread then...
Hu-Gu, Brat!!.... sorry for my Cyrillic accent smile
>to Espér
Thx for a second try smile Hope it's gonna help....

Last edited by BastovBros; 07/07/09 18:03.

a generator of dull questions smile
Re: mouse coordinates [Re: BastovBros] #277344
07/08/09 21:25
07/08/09 21:25
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
another question related to mouse movement: I would like to trap my mouse pointer in the center of the screen, but in a circle field. I've found a code in one AUM and it works fine:
Quote:
// trap the mouse in an area that has 200x100 pixels and is located in the center of the screen
var area_x = 200;
var area_y = 100;
BMAP* pointer_tga = "pointer.tga";
function mouse_startup()
{
VECTOR temp1_pos, temp2_pos;
mouse_mode = 2;
mouse_map = pointer_tga;
while (1)
{
vec_set(mouse_pos, mouse_cursor);
temp1_pos.x = (screen_size.x - area_x) / 2;
temp2_pos.x = (screen_size.x + area_x) / 2;
mouse_pos.x = clamp(mouse_pos.x, temp1_pos.x, temp2_pos.x);
temp1_pos.y = (screen_size.y - area_y) / 2;
temp2_pos.y = (screen_size.y + area_y) / 2;
mouse_pos.y = clamp(mouse_pos.y, temp1_pos.y, temp2_pos.y);
wait(1);
}
}

though it keeps the mouse in a rectangular field.....
Any idea to keep the mouse in a circle field? I have been trying to write a code myself, but with no successful result frown
Thanks in advance.


a generator of dull questions smile
Re: mouse coordinates [Re: BastovBros] #277347
07/08/09 21:32
07/08/09 21:32
Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
VeT Offline

Serious User
VeT  Offline

Serious User

Joined: Aug 2004
Posts: 1,345
Kyiv, Ukraine
//Hu-Gu, Brat!!.... sorry for my Cyrillic accent
No problems, as you see, i'm from Ukraine too smile

//Any idea to keep the mouse in a circle field?
First idea - is to calculate distance between center point (center of the circle) and maximum cursor distance (point on the radius of the circle)


1st prize: Lite-C and Newton 2.17 by Vasilenko Vitaliy

Newton2 videos: http://tinyurl.com/NewtonVideos
LiteC+Newton2 discussion: http://tinyurl.com/NewtonWrapperDiscussion
Latest LiteC+Newton2 version(v23, from 29.10.2009): http://depositfiles.com/files/ae1l0tpro
Re: mouse coordinates [Re: BastovBros] #277354
07/08/09 22:22
07/08/09 22:22
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
replace:
Code:
var area_x = 200;
var area_y = 100;
[...]
VECTOR temp1_pos, temp2_pos;

[...]

vec_set(mouse_pos, mouse_cursor);
temp1_pos.x = (screen_size.x - area_x) / 2;
temp2_pos.x = (screen_size.x + area_x) / 2;
mouse_pos.x = clamp(mouse_pos.x, temp1_pos.x, temp2_pos.x);
temp1_pos.y = (screen_size.y - area_y) / 2;
temp2_pos.y = (screen_size.y + area_y) / 2;
mouse_pos.y = clamp(mouse_pos.y, temp1_pos.y, temp2_pos.y);



by:
Code:
var radius = 80; //a circle of radius 100
[...]
VECTOR temp1_pos, temp2_pos;

[...]

vec_set(temp1_pos, mouse_cursor); //set temp1_pos to mouse_cursor coordinates

//set temp2_pos to middle of the screen
temp2_pos.x = screen_size.x/2;
temp2_pos.y = screen_size.y/2;
temp2_pos.z = 0; //don't forget this!! .z wont be at 0 initially, will turn in awkward values at vec_dist)

//mouse is outside circle
if( vec_dist( temp1_pos, temp2_pos ) > radius ) {
//compute new position on the circle
vec_diff(temp1_pos, temp1_pos, temp2_pos); //direction from temp2 to temp1
vec_normalize(temp1_pos, radius); //normalize to the radius
vec_add( temp1_pos, temp2_pos ); //add from screen center
vec_set( mouse_pos, temp1_pos );
}
else {
vec_set( mouse_pos, temp1_pos );
}



Last edited by Joozey; 07/09/09 12:52.

Click and join the 3dgs irc community!
Room: #3dgs
Re: mouse coordinates [Re: Joozey] #277443
07/09/09 10:08
07/09/09 10:08
Joined: Jul 2008
Posts: 128
Ukraine
BastovBros Offline OP
Member
BastovBros  Offline OP
Member

Joined: Jul 2008
Posts: 128
Ukraine
>to Vet
I've already had this idea, but my programming skills are to bad to write the code properly...
>to Joozey
THANKS A LOT!!!! this code is awesome! much simplier than mine (which in addition didn't work at all). I've learned a new function for me - vec_normilize smile


a generator of dull questions smile
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