Hi all.
ok i am a beginner in VS C++ and darkgdk.I have a problem in my code which is really annoying me as i can't find the mistake.Here's the code:
// 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"
int returnobject ( int );
void trdcam ( int , int , float , float );
// 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 );
SC_Start();
//////////////////////////player
int pla=returnobject(60);
dbMakeObjectSphere (pla,5);
SC_SetupObject(pla,0,0);
dbPositionObject (pla,0,7,0);
int cam=1;
dbMakeCamera(cam);
dbPositionCamera(cam,0,5,-25);
////////player///////////////////////
//////////////////////terrrrrrrrrrrrain
int ter[30];
for(int p=0;p<30;p++)
{
ter[p]=returnobject(60);
dbMakeObjectBox (ter[p],10,2,10);
SC_SetupObject(ter[p],0,0);
dbPositionObject (ter[p],dbRND(100),0,dbRND(100));
dbColorObject (ter[p],dbRGB(255,25,25));
}
//terrain///////////////////////////////////
//just for test
int objectx;
int objecty;
objectx=returnobject(60);
objecty=returnobject(1000);
dbMakeObjectBox(objectx,1000,1,1);
dbMakeObjectBox(objecty,1,1,1000);
//just for test//////////////////////////
// our main loop
while ( LoopGDK ( ) )
{
//player
if (dbUpKey()==1)
dbMoveObject (pla,1);
if (dbLeftKey()==1)
dbTurnObjectLeft (pla,1);
if (dbRightKey()==1)
dbTurnObjectRight (pla,1);
if (dbDownKey()==1)
dbMoveObject (pla,-1);
trdcam (pla,cam,5.0,4.0);
SC_UpdateObject(pla);
//player/////////////////
//terrain
for (int p=0;p<30;p++)
{
SC_UpdateObject(ter[p]);
}
////terrain////////////////
// update the screen
dbSync ( );
}
// return back to windows
return;
}
int returnobject (int max)
{
int l,e,obj;
for( e=1;e<=max;e++)
{
obj=dbObjectExist(e);
if (obj==0)
{
l=e;
break;
}
}
return (l);
}
void trdcam (int obj,int cam,float dist,float hei)
{
float x,y,z;
x=dbObjectPositionX(obj);
y=dbObjectPositionY(obj);
z=dbObjectPositionZ(obj);
float ay=dbObjectAngleY(obj);
ay=dbWrapValue(ay);
dbSetCameraToFollow(cam,x,y,z,ay,dist,hei,20.0,0.0);
}
Now the problem i guess is in "objecty" . Thanks in advance.
ALLAH IS THE GREATEST
May he forgive me