Right, now everything works and whatever, but now I have the amusing issue that nothing gets repositioned... Everything stays at 0,0,0 even though I told it not to.
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
#include "DarkPhysics.h"
//Define Functions
void CenterScreen(void);
void LoadWorld(void);
void LoadPlayer(int ID, int IDX);
void HandleControls(void);
//Define Globals
int WorldID = 1;
int SkyID = 2;
int SkyImg = 1;
int Data_CharCtrl = 3;
int ObjectID = 4;
int Moving = 0;
float OldCamAngleY;
float CameraAngleY;
int key;
// the main entry point for the application is this function
void DarkGDK ( void )
{
//Change the window
dbSetWindowPosition (0, 0);
dbSetDisplayModeAntialias(1280,1024,32,1,8,8);
dbSetWindowOff();
dbHideMouse();
dbAutoCamOff();
dbPhyStart();
//Set Sync on
dbSyncOn ( );
dbSyncRate ( 60 );
//dbColorBackdrop(1);
//Data
struct Data_Player
{
char* Username;
int Gender;
int Class;
int ObjectID;
int MapID;
float PosX;
float PosY;
float PosZ;
int Moving;
};
struct Data_Class
{
char* Name;
int MaleModel;
int FemaleModel;
int MaleID;
int FemaleID;
int MaleSpeed;
int MaleScale;
int FemaleSpeed;
int FemaleScale;
};
Data_Player Data_Player[100];
Data_Class Data_Class[100];
dbSetDir("Data");
//Load the world
dbText(dbScreenWidth()/2-30,dbScreenHeight()/2-4,"Loading...");
dbSync();
LoadWorld();
dbText(dbScreenWidth()/2-30,dbScreenHeight()/2-4,"Loading...");
dbSync();
LoadPlayer(ObjectID, Data_CharCtrl);
dbText(dbScreenWidth()/2-30,dbScreenHeight()/2-4,"Loading...");
dbSync();
dbPositionCamera(1304, 643, -2480);
dbPhySetGravity(0, -98, 0);
while ( LoopGDK ( ) )
{
//Make the camera follow the player
//dbSetCameraToFollow(dbObjectPositionX(ObjectID),dbObjectPositionY(ObjectID),dbObjectPositionZ(ObjectID),dbObjectAngleY(ObjectID)-180,100,100,10,0);
dbPositionObject(ObjectID,dbObjectPositionX(Data_CharCtrl),dbObjectPositionY(Data_CharCtrl),dbObjectPositionZ(Data_CharCtrl));
OldCamAngleY = CameraAngleY;
CameraAngleY = dbWrapValue(CameraAngleY+dbMouseMoveX()*0.8);
dbYRotateObject(ObjectID, dbCurveAngle(CameraAngleY,OldCamAngleY,17));
dbYRotateObject(Data_CharCtrl, dbCurveAngle(CameraAngleY,OldCamAngleY,17));
//Handle Controls
HandleControls();
dbText(0,0,dbStr(dbObjectPositionX(ObjectID)));
dbText(0,20,dbStr(dbObjectPositionY(ObjectID)));
dbText(0,40,dbStr(dbObjectPositionZ(ObjectID)));
dbText(0,60,"***");
dbText(0,80,dbStr(OldCamAngleY));
dbText(0,100,dbStr(CameraAngleY));
// update the screen
dbPhyUpdate();
dbSync();
}
// return back to windows
return;
}
void CenterScreen(void)
{
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
int CurrentScreenWidth = dbScreenWidth();
int CurrentScreenHeight = dbScreenHeight();
dbSetWindowPosition ((cx - CurrentScreenWidth)/2, (cy - CurrentScreenHeight)/2);
}
void LoadWorld(void)
{
char* Path = dbGetDir();
dbSetDir("Maps\\1");
dbLoadObject("levelbank\\testlevel\\universe.dbo", WorldID);
dbSetObjectSmoothing(WorldID,100);
dbSetObjectCull(WorldID,1);
dbSetObjectLight(WorldID,1);
dbPositionCamera(1304, 643, -2480);
dbPhyMakeRigidBodyStaticMesh(WorldID);
dbSetDir(Path);
}
void LoadPlayer(int ID, int IDX)
{
dbLoadObject("\\Characters\\1\\Object.dbo",ID);
dbScaleObject(ID,80.0,80.0,80.0);
dbSetObjectCull(ID,1);
//dbSetShadowShadingOn(ID,-1,1000,1);
dbMakeObjectSphere(IDX,10);
dbHideObject(IDX);
dbPhyMakeBoxCharacterController(IDX, 1304, 643, -2480, 10, 40, 10, 1, 10.5, 60.0);
dbPositionObject(ID, 1304, 643, -2480);
dbPositionObject(IDX, 1304, 643, -2480);
}
void HandleControls(void)
{
key = 0;
//Turn Left
if (dbKeyState(16) == 1)
{
if (Moving != 2)
{
key = 1;
dbYRotateObject(Data_CharCtrl,dbObjectAngleY(Data_CharCtrl)-3);
dbYRotateObject(ObjectID,dbObjectAngleY(Data_CharCtrl)-3);
CameraAngleY = dbObjectAngleY(Data_CharCtrl);
Moving = 0;
}
}
//Turn Right
if (dbKeyState(18) == 1)
{
if (Moving != 2)
{
key = 1;
dbYRotateObject(Data_CharCtrl,dbObjectAngleY(Data_CharCtrl)+3);
dbYRotateObject(ObjectID,dbObjectAngleY(Data_CharCtrl)+3);
CameraAngleY = dbObjectAngleY(Data_CharCtrl);
Moving = 0;
}
}
//Forward
if (dbKeyState(17) == 1)
{
if (dbKeyState(30) == 0)
{
if (dbKeyState(32) == 0)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, -150.0);
if (Moving != 3)
{
Moving = 1;
}
}
else
{
if (dbKeyState(17) == 1)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, -100.0);
if (Moving != 3)
{
Moving = 1;
}
}
}
}
else
{
if (dbKeyState(17) == 1)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, -100.0);
if (Moving != 3)
{
Moving = 1;
}
}
}
}
//Backward
if (dbKeyState(31) == 1)
{
if (dbKeyState(30) == 0)
{
if (dbKeyState(32) == 0)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, 150.0);
if (Moving != 5)
{
Moving = 4;
}
}
else
{
if (dbKeyState(31) == 1)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, 100.0);
if (Moving != 3)
{
Moving = 1;
}
}
}
}
else
{
if (dbKeyState(31) == 1)
{
key = 1;
dbPhyMoveCharacterController(Data_CharCtrl, 100.0);
if (Moving != 3)
{
Moving = 1;
}
}
}
}
if (key == 0)
{
dbPhyMoveCharacterController(Data_CharCtrl, 1);
dbPhyMoveCharacterController(Data_CharCtrl, -1);
if (Moving = 3){Moving = 0;}
if (Moving = 5){Moving = 0;}
if (Moving = 7){Moving = 0;}
if (Moving = 9){Moving = 0;}
}
}
Any pointers as to where I went wrong? Or is this an issue with 7.4a?
It's not the world that turns against you, it's you that turns against the world.