///////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include "physX.h"
///////////////////////////////////////////////////////////////
VECTOR ball_speed;
ENTITY* ball;
function main()
{
fps_max = 140;
level_load("roller.wmb"); // load the level
wait (2); // wait until the level is loaded
shadow_stencil=1;
ball = ent_create ("ball.mdl", vector(-400, 0, 100), NULL); // create the ball
pX_setgravity (vector(0, 0, -386)); // set the gravity
pXent_settype (ball, PH_RIGID, PH_SPHERE); // set the physics entity type
pXent_setmass (ball, 3, PH_SPHERE); // and its mass
pXent_setfriction (ball, 80); // set the friction
pXent_setdamping (ball, 40, 40); // set the damping
pXent_setelasticity (ball, 50); // set the elasticity
while (1)
{
ball_speed.x = 25 * (key_cur - key_cul); // move the ball using the cursor keys
ball_speed.y = 25 * (key_cuu - key_cud); // 25 sets the x / y movement speeds
ball_speed.z = 0; // no need to move on the vertical axis
pXent_addtorqueglobal (me, ball_speed); // add a torque (an angular force) to the ball
camera.x = ball.x - 300; // keep the camera 300 quants behind the ball
camera.y = ball.y; // using the same y with the ball
camera.z = 1000; // and place it at z = 1000 quants
camera.tilt = -60; // make it look downwards
wait (1);
}
}