About Store Forum Documentation Contact
Donations:
309$/mo



Post Reply 
World not creating with chr.
Author Message
treavor09 Offline
Member

Post: #1
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.)
05-04-2013 07:20 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: World not creating with chr.
Hello!

Some of your code issues:

Game.World.update already calls Physics.startSimulation().stopSimulation so please don't call it manually

You're using "ground" but you're not creating it anywhere.
05-04-2013 09:24 PM
Find all posts by this user Quote this message in a reply
treavor09 Offline
Member

Post: #3
RE: World not creating with chr.
allright thanks alot for the quick response still working on creating the "ground"
05-06-2013 06:02 PM
Find all posts by this user Quote this message in a reply
treavor09 Offline
Member

Post: #4
RE: World not creating with chr.
so im still having a noob moment when you say create land im looking though the tutorials to find what your're talking about but i cant seem to find it
05-06-2013 08:57 PM
Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #5
RE: World not creating with chr.
Hi Treavor,

What esenthel is referring too is you have reference Actor ground and ground.draw() but you never set what "ground" is (like you did with player.create). Why are you creating a "ground" actor? The ground should be the heightmap of your world.

Also, i see you did not specify a location for your player. Make sure (0,0,0) has ground under it or you will fall through (i am pretty sure (0,0,0) is where it will place it by default but not sure).
(This post was last modified: 05-06-2013 10:13 PM by Ozmodian.)
05-06-2013 09:05 PM
Find all posts by this user Quote this message in a reply
treavor09 Offline
Member

Post: #6
RE: World not creating with chr.
so use something like this? /////////////////////////////////////////////////////////////////////////////////////virtual void pos (C Vec &pos 0,0,0 );

question is where would i put this inside the class Player : Game.Chr area or under the update func inside of it i just keep getting formatting errors
(This post was last modified: 05-06-2013 09:25 PM by treavor09.)
05-06-2013 09:09 PM
Find all posts by this user Quote this message in a reply
treavor09 Offline
Member

Post: #7
RE: World not creating with chr.
solved thanks guys
(This post was last modified: 05-07-2013 12:28 AM by treavor09.)
05-06-2013 11:03 PM
Find all posts by this user Quote this message in a reply
Post Reply