Gamestudio Links
Zorro Links
Newest Posts
Zorro version 3.0 prerelease!
by Grant. 02/24/26 22:21
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, clint000, Grant, chsmac85, Martin_HH), 5,858 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
movement problems #327223
06/05/10 10:18
06/05/10 10:18
Joined: Jan 2010
Posts: 20
FraK Offline OP
Newbie
FraK  Offline OP
Newbie

Joined: Jan 2010
Posts: 20
Well, I wanted to start programming a little game, in which you can move around with the mouse. The mouse_force.y is responsible for the speed and mouse_force.x for the direction, but in fact it doesn't work! Here's my code:



VECTOR boden;
var speed_down = 0;
var dist_down = 0;
var dist_ahead = 0;

action Spieler()
{
player = my;


c_setminmax(my);
wait(1);

camera_pos();

set(my,POLYGON);



vec_for_min(boden,me);



my.pan += 5 * mouse_force.x * time_step;


if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME |IGNORE_PASSABLE | USE_BOX) > 0)
{

dist_down = my.z + boden.z - target.z;
}

else
{
dist_down = 0;

}

if(dist_down>0)
{
dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
}
else
{
speed_down = 0;
}

var dist_ahead = 5* mouse_force.y* time_step;
c_move(me,vector(dist_ahead,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE| GLIDE);

}

Re: movement problems [Re: FraK] #327229
06/05/10 10:57
06/05/10 10:57
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You don't have a while loop, now the engine 'looks into' the function only once, but it has to 'look into it' again and again to apply the values of the mouse_force each time anew.


VECTOR boden;
var speed_down = 0;
var dist_down = 0;
var dist_ahead = 0;

action Spieler()
{
player = my;


c_setminmax(my);
wait(1);

camera_pos();

set(my,POLYGON);

while(1)
{

vec_for_min(boden,me);



my.pan += 5 * mouse_force.x * time_step;


if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME |IGNORE_PASSABLE | USE_BOX) > 0)
{

dist_down = my.z + boden.z - target.z;
}

else
{
dist_down = 0;

}

if(dist_down>0)
{
dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
}
else
{
speed_down = 0;
}

var dist_ahead = 5* mouse_force.y* time_step;
c_move(me,vector(dist_ahead,0,0),vector(0,0,-dist_down),IGNORE_PASSABLE| GLIDE);
wait(1);
}
}

Re: movement problems [Re: Pappenheimer] #327231
06/05/10 11:25
06/05/10 11:25
Joined: Jan 2010
Posts: 20
FraK Offline OP
Newbie
FraK  Offline OP
Newbie

Joined: Jan 2010
Posts: 20
thanx a lot Pappenheimer for the response! It finally works!!
But I have one more question:(I'm not sure if I'm supposed to create a new thread)
I need a simple ball-physics script: including bouncing, rolling...

There's mine, it works somehow, the movement stucks and the ball is bouncing at one point as crazy!!
here's my script:
function physics()
{
phent_settype(my, PH_RIGID, PH_SPHERE);
phent_setmass(my, 0.1, PH_SPHERE);
phent_setfriction(my, 5);
phent_setdamping(my,10, 10);
phent_setelasticity(my, 1, 0);
temp.x = 0;
temp.y = 0;
temp.z = -380;
ph_setgravity(temp);
phent_setmaxspeed (my, 1000, 5);

}



function reset_physics()
{
phent_settype(player, 0, 0);

phent_settype(player, PH_RIGID, PH_SPHERE);
phent_setmass(player, 0.1, PH_SPHERE);
phent_setfriction(player, 5);
phent_setdamping(player,0, 50);
phent_setelasticity(player, 10, 0);
temp.x = 0;
temp.y = 0;
temp.z = -380;
ph_setgravity(temp);
phent_setmaxspeed (player, 1000, 10);
}



Last edited by FraK; 06/05/10 11:26.
Re: movement problems [Re: FraK] #327236
06/05/10 11:53
06/05/10 11:53
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
It is okay to start a complete new thread for this, because it is a complete new theme, but you can edit the topic name, to give the others a better hint about what your question is about now.

I can't help you with physics, because I never worked with it.

Re: movement problems [Re: Pappenheimer] #327238
06/05/10 12:01
06/05/10 12:01
Joined: Jan 2010
Posts: 20
FraK Offline OP
Newbie
FraK  Offline OP
Newbie

Joined: Jan 2010
Posts: 20
Nevertheless thanx, you helped me a lot!:)


Gamestudio download | 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