Hi lucasa12.
#include "DarkGDK.h"
#include "SC_Collision.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 30 );
dbPrint ( "Please wait loading model..." );
dbSync ( );
dbSync ( );
//dbLoadObject ( "carrinho.x", 1 );
dbMakeObjectCube(1,50);
dbPositionObject(1,0,0,200);
//dbLoadObject ( "colonel-x.x", 2);
dbMakeObjectCube(2,30);
//Init Sparky
SC_Start();
//Setup the objects so sparky can use them
SC_SetupObject(1,1,2);
SC_SetupObject(2,1,2);
float fOldX,fOldY,fOldZ,fX,fY,fZ;
float objx = 0;
float objy = 0;
float objz = 0;
dbPositionCamera ( 0, 50, -80 );
while ( LoopGDK ( ) )
{ //Old position of your moving cube
fOldX = dbObjectPositionX(1);
fOldY = dbObjectPositionY(1);
fOldZ = dbObjectPositionZ(1);
if ( dbEscapeKey ( ) )
return;
if ( dbUpKey() == 1 )
{
dbMoveObject (1,5.0f);
dbSetObjectSpeed (1,1000000);
}
if ( dbDownKey() == 1)
{
dbMoveObject (1,-5.0f);
dbSetObjectSpeed (1,1000000);
}
if (dbRightKey() ==1)
{
dbTurnObjectRight (1,5);
dbSetObjectSpeed (1,500000);
}
if (dbLeftKey() ==1)
{
dbTurnObjectLeft (1,5);
dbSetObjectSpeed (1,50000);
}
//New position of your moving cube
fX = dbObjectPositionX(1);
fY = dbObjectPositionY(1);
fZ = dbObjectPositionZ(1);
//We make a sphere of a radius of 50
//To check on the collision group 1
//to test if a collision has been made
//between the old and new positions
DWORD dRes = SC_SphereCastGroup (1,fOldX,fOldY,fOldZ,fX,fY,fZ,50,1);
//If a collision was made
//We put the cube on the old position
if(dRes != 0)
{
dbPositionObject(1,fOldX,fOldY,fOldZ);
}
SC_UpdateObject(1);
// update
dbSync ( );
}
}
This should work.just past it and test it.
The identation is messed up ,sorry about that.
Im from Argentina so we are neighbours