#include <acknex.h>
#include <default.c>
#include <ackphysx.h>
//GLOBAL VARIABLES
var MassOfBall = 0;
var AngleOfSlope = 0;
var CoefficientOfFriction = 0;
var LinearDamping = 10;
var AngularDamping = 10;
var Elasticity = 50;
var ForceInNewtons = 10;
var Mass = 1;
var Velocity;
var Acceleration;
var Start = 0;
function IncreaseMass()
{
MassOfBall = MassOfBall+1;
}
function IncreaseAngle()
{
AngleOfSlope = AngleOfSlope+1;
}
function IncreaseFriction()
{
CoefficientOfFriction = CoefficientOfFriction+1;
}
function DecreaseMass()
{
MassOfBall = MassOfBall-1;
MassOfBall = clamp(MassOfBall, 0, 100);
}
function DecreaseAngle()
{
AngleOfSlope = AngleOfSlope-1;
AngleOfSlope = clamp(AngleOfSlope, 0, 360);
}
function DecreaseFricion()
{
CoefficientOfFriction = CoefficientOfFriction-1;
CoefficientOfFriction = clamp(CoefficientOfFriction, 0, 100);
}
PANEL* homescreen =
{
bmap = "SimpleInclinedPlaneSplash.jpg";
button(610, 165, "IncreaseButtonDown.png", "IncreaseButton.png", "IncreaseButtonDown.png", IncreaseMass, NULL, NULL);
button(610, 185, "DecreaseButtonDown.png", "DecreaseButton.png", "DecreaseButtonDown.png", DecreaseMass, NULL, NULL);
button(610, 230, "IncreaseButtonDown.png", "IncreaseButton.png", "IncreaseButtonDown.png", IncreaseAngle, NULL, NULL);
button(610, 250, "DecreaseButtonDown.png", "DecreaseButton.png", "DecreaseButtonDown.png", DecreaseAngle, NULL, NULL);
button(610, 295, "IncreaseButtonDown.png", "IncreaseButton.png", "IncreaseButtonDown.png", IncreaseFriction, NULL, NULL);
button(610, 315, "DecreaseButtonDown.png", "DecreaseButton.png", "DecreaseButtonDown.png", DecreaseFricion, NULL, NULL);
button(30, 480, "StartSimulationButtonDown.png", "StartSimulationButton.png", "StartSimulationButtonDown.png", StartSimulation, NULL, NULL);
digits(307, 170, 3, "Arial#28b", 1, MassOfBall);
digits(322, 235, 3, "Arial#28b", 1, AngleOfSlope);
digits(463, 304, 3, "Arial#28b", 1, CoefficientOfFriction);
layer = 1;
flags = SHOW | OVERLAY;
}
function StartSimulation()
{
//if(Monster != NULL && LevelFile != NULL) //this check didn't work.
{
homescreen.flags = 0;
level_load("HollowCube.wmb");
Start = 1;
}
}
TEXT* InputedVariables =
{
pos_x = 10;
pos_y = 10;
layer = 1;
font = "Segoe_Print#20";
string ("Mass of Ball:\nAngle Of Slope:\nCoefficient of Friction:");
}
TEXT* WatchedVariables =
{
pos_x = 600;
pos_y = 10;
layer = 1;
font = "Segoe_Print#20";
string ("Velocity:\nAcceleration:\nTime:\nDisplacement:");
}
PANEL* Variables =
{
digits(100, 10, 3, "Segoe_Print#20", 1, MassOfBall);
digits(120, 30, 3, "Segoe_Print#20", 1, AngleOfSlope);
digits(165, 50, 3, "Segoe_Print#20", 1, CoefficientOfFriction);
}
function DisplayVariables()
{
}
action InclineThePlane()
{
wait(-3);
my.tilt = AngleOfSlope;
}
action BallPhysics()
{
pXent_settype (me, PH_RIGID, PH_SPHERE); // set the physics entity type
pXent_setfriction (me,CoefficientOfFriction); // set the friction on the ground
pXent_setdamping (me,LinearDamping,AngularDamping); // set the damping
pXent_setelasticity (me,Elasticity); // set the elasticity
pXent_setmass(me, MassOfBall); //set the mass
}
function main()
{
physX_open();
mouse_mode = 4;
while(Start==0)
wait(1);
ENTITY* InclinedPlane = ent_create("InclinedPlane.wmb", vector(160, 16, -186), InclineThePlane);
ENTITY* Ball = ent_create("ball.mdl", vector(InclinedPlane.x + 180, InclinedPlane.y, InclinedPlane.z+31), BallPhysics);
InputedVariables.flags = SHOW | SHADOW;
Variables.flags = SHOW;
WatchedVariables.flags = SHOW;
camera.x = Ball.x; // keep the camera 300 quants behind the ball
camera.y = Ball.y - 440; // using the same y with the ball
camera.z = Ball.z; // and place it at z = 1000 quants
camera.pan = camera.pan + 110;
//camera.tilt = -60; // make it look downwards
}