World not creating with chr.
So this is the code i have so far but whenever it runs i seem to just fall though the world im sure its a silly error but i cant seem to find it.
//////////////////////////////////////////////////////////////////////////////
Game.ObjMemx<Game.Item> Items;
Game.ObjMemx<Game.Chr> Chrs;
class Player : Game.Chr // extend character class by defining a player class based on the character
{
virtual Bool update() // here we'll update the player (please note that this is a virtual method)
{
// here we update character input according to mouse and keyboard
// before we set the input, we need to check if the character isn't controlled by an automatic action
if(action)
{
// if it's controlled by an action we leave the input with no changes,
// however we can optionally break that action, by pressing for example movement keys
if(Kb.b(KB_W) || Kb.b(KB_S) || Kb.b(KB_A) || Kb.b(KB_D) || Kb.b(KB_Q) || Kb.b(KB_E))actionBreak();
}
if(!action) // if the character isn't controlled by an automatic action, we can set the input
{
// turn & move
input.turn.x=Kb.b(KB_Q)-Kb.b(KB_E);
input.turn.y=Kb.b(KB_T)-Kb.b(KB_G);
input.move.x=Kb.b(KB_D)-Kb.b(KB_A);
input.move.z=Kb.b(KB_W)-Kb.b(KB_S);
input.move.y=Kb.b(KB_SPACE)-Kb.b(KB_LSHIFT);
// dodge, crouch, walk, jump
input.dodge = Kb.bd(KB_D)-Kb.bd(KB_A);
input.crouch= Kb.b (KB_LSHIFT);
input.walk = Kb.b (KB_LCTRL );
input.jump =(Kb.bp(KB_SPACE) ? 3.5 : 0);
// mouse turn
Flt max=DegToRad(900)*Time.d();
angle.x-=Mid(Ms.d().x*1.7, -max, max);
angle.y+=Mid(Ms.d().y*1.7, -max, max);
}
return super.update(); // call Game.Chr.update on which Player is based on
}
}
/******************************************************************************/
Actor ground; // ground actor
Player player; // player
/******************************************************************************/
void InitPre()
{
EE_INIT();
App.flag=APP_MS_EXCLUSIVE;
Cam.dist=5;
}
/******************************************************************************/
bool Init()
{
Physics.create(EE_PHYSX_DLL_PATH);
Game.World.activeRange(D.viewRange());
// we need to tell the world 'which class handles which object type'
// this is done by assigning memory containers to certain Object Types
Game.World.setObjType(Items, OBJ_ITEM) // set 'Items' memory container for 'OBJ_ITEM' objects
.setObjType(Chrs , OBJ_CHR ); // set 'Chrs' memory container for 'OBJ_CHR' objects
// now when the engine is set up properly we can start a 'new game' with a builded world
Game.World.New(UID(805235648, 1182540910, 323947702, 167895674)); // create the world by giving path to world
if(Game.World.settings().environment) // if the world has environment settings (like sun, ambient, sky, ..)
Game.World.settings().environment->set();
Game.World.update(Cam.at);
player.create(*Game.Objs(UID(1281272712, 1339182797, 2487130559, 821839567))); // create player from object parameters
return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
if(Kb.bp(KB_ESC))return false;
Physics.startSimulation().stopSimulation();
player.update(); // update player
Cam.setSpherical(player.ctrl.actor.pos()+Vec(0, 1, 0), player.angle.x, player.angle.y, 0, Cam.dist*ScaleFactor(Ms.wheel()*-0.2)).updateVelocities().set(); // update camera according to player angles and mouse wheel
Game.World.update(Cam.at);
return true;
}
/******************************************************************************/
void Render()
{ Game.World.draw();
switch(Renderer())
{
case RM_PREPARE:
{
player.drawPrepare();
LightDir(!(Cam.matrix.x-Cam.matrix.y+Cam.matrix.z)).add();
}break;
}
}
void Draw()
{
Renderer(Render);
if(Renderer.rebuildDepthNeededForDebugDrawing())Renderer.rebuildDepth();
ground.draw(); // draw ground actor
}
(This post was last modified: 05-04-2013 07:37 PM by treavor09.)
|