Thank you, before this I was declaring all my variables as globals (my last C++ book told me that that was a bad practice - for debugging sake). However, if I declare the global float fArgA and 'forget' to initialise it then I get no error message, is that something to do with compiler or what?
btw the example which I converted was designed with DBPro
I also noticed that some of the commands in the example didn’t take the same parameters as the updated commands in the SDK
- some didn’t even exist, in the example "set shadow shading on" took 4 arguments whereas "dbSetShadowShadingOn()" only takes 1, the DBP command "set shadow position" also appears to be excluded from the SDK. This could be an error in the code base post, or the SDK has slightly different commands.
[edit] Does the dbInKey() command even work?
Here is the new updated version in which everything works apart from the "if (dbInKey()=="")" statements:
#include "DarkSDK.h"
void movelight(float fArgX,float fArgY,float fArgZ, int nArgo);
void DarkSDK ( void )
{
float fX=0;
float fY=0;
float fZ=0;
fX=1;
int nShader=1;
dbSyncOn();
dbSyncRate(40);
dbInk(RGB(0,0,255),0);
dbBox(0,0,16,16);
dbGetImage(1,0,0,16,16);
dbHideLight(0);
dbSetAmbientLight(40);
dbMakeMatrix(1,1000,1000,64,64);
dbPrepareMatrixTexture(1,1,1,1);
dbPositionMatrix(1,-250,0,-250);
int o=1;
for (int f=0;f<315; f+=45)
{
o++;
dbMakeObjectCube(o,20);
dbTextureObject(o,1);
dbSetShadowShadingOn(o);
dbPositionObject(o,100*dbSin(f),10,100*dbCos(f));
}
o++;
dbMakeObjectSphere(o,-10);
dbMakeLight(1);
dbSetPointLight(1,0,0,0);
dbSetLightRange(1,1000);
movelight(fY,fZ,fX,o);
dbPositionCamera(-20,8,-120);
dbPointCamera(0,0,0);
dbInk(RGB(255,255,255),1);
while (LoopSDK() && !dbEscapeKey())
{
dbText(0,0,"q + z = move light up and down");
dbText(0,20,"cursors to move around");
dbText(0,40,dbStr(dbScreenFPS()));
dbControlCameraUsingArrowKeys(0,2,2);
if (dbInKey()=="q") { fY++; movelight(fX,fY,fZ,o); }
if (dbInKey()=="z") { fY--; movelight(fX,fY,fZ,o); }
dbSync();
}
}
void movelight(float fArgX,float fArgY, float fArgZ, int nArgo)
{
dbPositionLight(1,fArgX,fArgY,fArgZ);
dbPositionObject(nArgo,fArgX,fArgY,fArgZ);
return;
}