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
3 registered members (AndrewAMD, TraderTom, Akow), 1,388 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Mouse code for lite-c #210773
06/12/08 19:02
06/12/08 19:02
Joined: Jan 2008
Posts: 9
tonyvans Offline OP
Newbie
tonyvans  Offline OP
Newbie

Joined: Jan 2008
Posts: 9
I am trying to get away from the templates (plus the movement code causes choppy movment when used) but I seam to be having issues getting free look on the mouse to work
I am using this code which doesn't work at the moment but I think I am close, can anyone help me with corrections?

action mouse_move
{
var mouse_sense = 1.5;
mouse_map = NULL;

mouse_pos.x = screen_size.x / 2;
mouse_pos.y = screen_size.y / 2;
mouse_mode = 1;
while(1)
{
while(mouse_right){mouse_mode = 0; wait(1);}
mouse_mode = 1;
mouse_pos.x = min(max(mouse_pos.x + 50 * mouse_sense * mouse_force.x * time,0),screen_size.x);
mouse_pos.y = min(max(mouse_pos.y - 50 * mouse_sense * mouse_force.y * time,0),screen_size.y);
wait(1);
}
}

thanks


GameStudio A7.07 Commercial
Re: Mouse code for lite-c [Re: tonyvans] #210774
06/12/08 19:10
06/12/08 19:10
Joined: Jul 2007
Posts: 959
nl
F
flits Offline
User
flits  Offline
User
F

Joined: Jul 2007
Posts: 959
nl
action mouse_move
{
mouse_map = NULL;

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


"empty"
Re: Mouse code for lite-c [Re: flits] #210781
06/12/08 20:43
06/12/08 20:43
Joined: Jan 2008
Posts: 9
tonyvans Offline OP
Newbie
tonyvans  Offline OP
Newbie

Joined: Jan 2008
Posts: 9
thank you for replying. ok first off I had a bit of a noob moment with this. My model was assigned the player_move code which is:
action player_move
{
player = me;
wait(1); //place a wait(1) here so the engine doesn't execute anything past this point yet
//so it can properly make sure that the pointer is set and I don't get pointer errors
camera.genius = player; //set camera so we can't look into our model
while(me != NULL) //while our player pointer is not = to the predefined NULL value the loop
//will continue
{
move_vec[0]=(key_w - key_s)*10*time; //moving forward and backward (was 3)
move_vec[1]=(key_a - key_d)*10*time; //strafing (was 2)
player.pan +=(key_q - key_e)*4*time;//turning left and right
ent_move(move_vec,NULLVECTOR);
if(move_vec[0] == 0 && move_vec[1] == 0)
{
idle_percent=(idle_percent+5*time)%100;
ent_animate(me,"stand",idle_percent,ANM_CYCLE);
}
else
{
//movement goes here
walk_percent=(walk_percent+ sign(move_vec[0])*5*time)%100;
ent_animate(player,"walk",walk_percent,ANM_CYCLE);
}
//camera updates
vec_set(Camera.x,player.x);
camera.z +=27;
camera.pan=player.pan;
temptilt +=(key_pgup - key_pgdn)*4*time;
if(key_home) {temptilt=0;}
if (temptilt >75)
{
temptilt = 75;
}
else
{
if (temptilt < -75)
{
temptilt = -75;
}
}
camera.tilt = 0 + temptilt;
wait(1); //place the needed pause at the end of a loop cycle so that the engine can handle
// other operations, else we will get an infinate loop and lock up our game
}
}

Now this code does work I have no issues moving around with the keyboard
So my mouse code wasn’t even being called. So I tried changing the model action to both my original mouse code and to yours (thinking I couldn’t move around but should be able to look about) all it does with either is the model loads half way though the floor and nothing works (chances are it is all me missing something) so I am guessing now what I need to do is add the mouse code somewhere to my player_move code and I will be good to go.....
thanks

Last edited by tonyvans; 06/12/08 20:47.

GameStudio A7.07 Commercial
Re: Mouse code for lite-c [Re: tonyvans] #210793
06/12/08 22:20
06/12/08 22:20
Joined: Jan 2008
Posts: 9
tonyvans Offline OP
Newbie
tonyvans  Offline OP
Newbie

Joined: Jan 2008
Posts: 9
I managed to get the mouse to work by changing
player.pan +=(key_q - key_e)*4*time;//turning left and right to
player.pan -=2 * mouse_force.x;
and
temptilt +=(key_pgup - key_pgdn)*4*time; to
temptilt +=2 * mouse_force.y;

my only issues now is how to get the cursor to lock to center screen and clean up the code
what would be ideal is if I could click "m" and I could switch from cursor no movement to lock mouse and have freelook work

Last edited by tonyvans; 06/12/08 22:22.

GameStudio A7.07 Commercial

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