function move_ball()
{
wait(1); //needed for c_updatehull
c_updatehull(my,0); //updates the collsision hull
VECTOR ball_dist; //needed for the movement
VECTOR save_pos; //stores the entity.pos (needed to find out if the position has changed)
VECTOR temp; //a temporary vector
var save_pan = 0; //stores the entity.pan (needed to find out if the pan has changed)
me.flags |= SHADOW;
while(enet_ent_globpointer(my) == -1) {wait(1);} //wait until the entity gets a global pointer
if(enet_get_connection() !=2)
{
//only do physics on the server:
// Now let's set the ball's physical properties.
phent_settype(me,PH_RIGID,PH_SPHERE);
phent_setmass(me,1,PH_SPHERE);
phent_setfriction(me,90);
phent_setelasticity(me,75,100);
phent_setdamping(me,30,5);
// We add a small speed to give it a little sidewards kick.
// phent_addvelcentral(me,vector(10,10,0));
// A ball game would be no fun without gravity.
ph_setgravity(vector(0,0,-500));
//only do the events on the server:
me.emask |= (ENABLE_FRICTION | ENABLE_PUSH | ENABLE_IMPACT);
me.push = 1;
me.event = bounce_event;
var timePassed = 0;
while(1) {
timePassed += time_frame;
if(timePassed >= 2) { //only send 8 times a second.
timePassed = 0;
enet_send_pos(enet_ent_globpointer(my),-1);
}
wait(1);
}
}
else
{
while(my) {
//do movement prediction in here
wait(1);
}
}
}