Hello people,
I'm trying to understand sparky's collision, and made a small program, but something is wrong...
I studied this forum, and found some results, but when I compare my program with theirs, it seems nothing is wrong, so I couldn't find a mistake. I'm just a beginner, so I'll put my code here for someone to get it corrected... Thank you.
// 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 "SC_Collision.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbMakeObjectSphere(1,20);
dbMakeObjectCube(3,50);
dbPositionObject(3,100,-10,100);
dbMakeLight(4);
dbPositionLight(4,0,60,0);
SC_Start();
SC_SetupObject(3,0,0);
SC_SetupObject(1,0,0);
float kolizija;
float nx, nz, sx, sz;
// our main loop
while ( LoopGDK ( ) )
{
sx=dbObjectPositionX(1);
sz=dbObjectPositionZ(1);
if (dbLeftKey()==1) dbYRotateObject(1,dbObjectAngleY(1)-2);
if (dbRightKey()==1) dbYRotateObject(1,dbObjectAngleY(1)+2);
if (dbUpKey()==1) dbMoveObject(1,1);
dbSetCameraToFollow(dbObjectPositionX(1),dbObjectPositionY(1),dbObjectPositionZ(1),dbObjectAngleY(1),40,20,10,0);
SC_UpdateObject(1);
nx=dbObjectPositionX(1);
nz=dbObjectPositionY(1);
kolizija=SC_SphereSlide(3,sx,0,sz,nx,0,nz,10,1);
if (kolizija > 0){
dbPositionObject(1, SC_GetCollisionSlideX(),SC_GetCollisionSlideY(),SC_GetCollisionSlideZ() );
} else {
dbPositionObject ( 1, nx, 0, nz);
}
dbSync ( );
}
// return back to windows
return;
}
Repetitio est mater studiorum!