Game.ObjMap<Player>Players;
void InitPre()
{
EE_INIT();
D.mode(1280,720);
D.sync(true);
D.viewRange(100);
D.viewFrom(0.45);
D.shadowMode(SHADOW_NONE);
D.viewFov(DegToRad(45));
Renderer.type(RT_SIMPLE).clear_color = Color(70, 130, 255, 255);
}
Bool Init()
{
// physics
Physics.create (EE_PHYSX_DLL_PATH, CSS_NONE);
Physics.gravity(Vec(0,-10.0,0));
Physics.timestep(PHYS_TIMESTEP_NUM);
Physics.precision(60);
// world
Game.World.setObjType(Players, OBJ_PLAYER);
Game.World.New(UID(3323205672, 1130099143, 1429786773, 618650229)); // create the world by giving path to world
return true;
}
void Shut()
{
Game.World.del();
}
/******************************************************************************/
Bool Update()
{
// inputs
if(Kb.bp(KB_ESC))return false;
// actor movement
if(Kb.b(KB_LEFT ))Players[0].actor.addVel(Vec( 0.2, 0, 0));
if(Kb.b(KB_RIGHT))Players[0].actor.addVel(Vec(-0.2, 0, 0));
if(Kb.b(KB_UP ))Players[0].actor.addVel(Vec( 0, 0, 0.2));
if(Kb.b(KB_DOWN ))Players[0].actor.addVel(Vec( 0, 0,-0.2));
if(Kb.b(KB_SPACE))Players[0].actor.addVel(Vec( 0, 0.5, 0));
if(Kb.bp(KB_X))Players[0].actor.freezePosX(true);
if(Kb.bp(KB_Z))Players[0].actor.freezePosZ(true);
if(Kb.bp(KB_Y))Players[0].actor.freezePosY(true);
Cam.transformByMouse(10, 100, CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
Game.World.update(Cam.at); // update the world to given position
return true;
}
void Render()
{
Game.World.draw(); // draw world (this is done outside of 'switch(Renderer())' because world automatically detects active rendering mode)
}
void Draw()
{
Renderer(Render);
Physics.draw();
// basic debug info
TextStyle ts;
ts.align = Vec2(1,-1);
ts.size = Vec2(0.05, 0.05);
Flt h = 0.04f;
Flt v = 0.04f;
Flt px = -D.w()+ v;
Flt py = D.h();
Vec2 pos(px,py);
py -=h; py -=h; py -=h;
D.text(ts,px,py,S+ "CONTROLS:"); py -=h;
D.text(ts,px,py,S+ "X or Z or Y = freeze actor axis X or Z or Y"); py -=h;
D.text(ts,px,py,S+ "ARROW LEFT or ARROW RIGHT = move actor X or Z"); py -=h; py -=h;
D.text(ts,px,py,S+ "ACTOR INFO:"); py -=h;
D.text(ts,px,py,S+ "actor.freezePosX = " + Players[0].actor.freezePosX()); py -=h;
D.text(ts,px,py,S+ "actor.freezePosZ = " + Players[0].actor.freezePosZ()); py -=h;
D.text(ts,px,py,S+ "actor.freezePosY = " + Players[0].actor.freezePosY()); py -=h;
}
/******************************************************************************/