The problem with auto collision is that you cant check for it - and as the camera and player position were always updated, they would eventually go through all walls. In addition, it appears that if there is a collision, the objects X,Y & Z values aren't updated
Whilst I can get the collision working with dbObjectCollision - you then loose sliding collision.
Edit:I think I've got it sorted
Edit of the edit:Try this :
#include "DarkSDK.h"
#include "stdio.h"
float CamX=0.0f;
float CamY=0.0f;
float CamZ=0.0f;
float OldCamX;
float OldCamY;
float PlayerX=0.0f;
float PlayerY=0.0f;
float PlayerZ=0.0f;
void init();
void init()
{
// set caption
dbSetWindowTitle("Tim vs the Black Lung");
CamX=10.0f;
CamY=10.0f;
CamZ=-10.0f;
PlayerX=5.0f;
PlayerY=7.0f;
dbPositionCamera(CamX,CamY,CamZ);
//dbPointCamera(10,10,0);
dbPositionLight(0,10,10,0);
//dbLoadImage("algaebricks.bmp",2000);
dbMakeObjectSphere(3000,1,10,20);
dbGhostObjectOn(3000,1);
dbPositionObject(3000,PlayerX,PlayerY,PlayerZ);
//dbSetObjectCollisionOn ( 3000 );
dbAutomaticObjectCollision(3000,0.4,1);
//dbMakeObjectPlane(4000,30,30);
dbMakeMatrix(4000,30,30,5,5);
//dbRandomizeMatrix(4000,5);
dbPrepareMatrixTexture(4000,2000,5,5);
dbPositionObject(4000,13.6f,16.5f,1.6);
//dbTextureObject(4000,2000);
//dbSyncRate(60);
}
void DarkSDK(void)
{
char* czLevel[50];
czLevel[0] = "1111111111";
czLevel[1] = "1000000001";
czLevel[2] = "1110000001";
czLevel[3] = "1000000001";
czLevel[4] = "1001111001";
czLevel[5] = "1000000001";
czLevel[6] = "1000000001";
czLevel[7] = "1000000111";
czLevel[8] = "1000000001";
czLevel[9] = "1111111111";
int BlockPosX = 0;
int ObjNum=1;
init();
dbAutoCamOff();
dbSyncOn();
for (int x = 0; x < 10 ;x ++)
{
for (int y = 10; y >= 0; y--)
{
BlockPosX++;
ObjNum++;
switch(czLevel[x][y])
{
case '1':
dbMakeObjectBox ( ObjNum, 3, 3, 3);
dbPositionObject( ObjNum,y*3,dbAbs((x-10)*3) ,0);
dbTextureObject(ObjNum,2000);
//dbSetObjectWireframe ( ObjNum, 1 ) ;
// not working
dbSetObjectCollisionOn(ObjNum);
//dbAutomaticObjectCollision(ObjNum,.4,0);
dbSetObjectCull ( ObjNum, 1 ) ;
break;
case '2':
dbMakeObjectBox ( ObjNum, 5, 3, 3);
dbPositionObject( ObjNum,y*3,x*3,0);
break;
}
}
}
while(LoopSDK())
{
OldCamX = CamX;
OldCamY = CamY;
if (dbEscapeKey())
return;
PlayerX=dbObjectPositionX(3000);
PlayerY=dbObjectPositionY(3000);
PlayerZ=dbObjectPositionZ(3000);
if(dbRightKey()==1){
PlayerX=PlayerX+0.01f;
}
if(dbLeftKey()==1){
PlayerX=PlayerX-0.01f;
}
if(dbUpKey()==1){
PlayerY=PlayerY+0.01f;
}
if(dbDownKey()==1){
PlayerY=PlayerY-0.01f;
}
CamX = dbCurveValue(PlayerX,OldCamX,300.0f);
CamY = dbCurveValue(PlayerY,OldCamY,300.0f);
dbPositionCamera(CamX,CamY,CamZ);
dbPositionObject(3000,PlayerX,PlayerY,PlayerZ);
dbSync();
}
}
Beware the cat... The alien... The heretic...