Hi guys,
So my sis got an entry for the projects for computer from the school.
So i am making one for her.
As the title says , i got through the first round , however i am failing at when someone press down key.
Here is the code so far:
// 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"
float distance(float,float,float,float,float,float);
void move();
float ay=0;
char text[200];
// 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 );
dbMaximiseWindow();
int pla=1;
dbMakeObjectBox(pla,2,4,1);
dbYRotateObject(pla,180);
dbFixObjectPivot(pla);
dbPositionObject(pla,50,0,50);
dbMakeCamera(pla);
dbPositionCamera(pla,50,2,-4+50);
dbPointCamera(pla,50,0,50);
dbMakeMatrix(1,100,100,10,10);
// our main loop
while ( LoopGDK ( ) )
{
move();
// update the screen
dbSync ( );
}
// return back to windows
return;
}
void move()
{
float x,y,z,camy,objy,acy;
float dis;
x=dbObjectPositionX(1);
y=dbObjectPositionY(1);
z=dbObjectPositionZ(1);
dis=distance(x,y,z,dbCameraPositionX(1),dbCameraPositionY(1),dbCameraPositionZ(1));
sprintf_s(text,200,"Distance=%f",dis);
dbText(0,0,text);
if(dbUpKey()||dbDownKey()||dbLeftKey()||dbRightKey())
{
objy=dbATANFULL(dbRightKey()-dbLeftKey(),dbUpKey()-dbDownKey());
objy=dbWrapValue(objy+dbCameraAngleY(1));
ay=dbWrapValue(dbCurveAngle(objy,ay,5));
dbMoveObject(1,0.1);
if(dis>5.0)
dbSetCameraToFollow(1,x,y,z,ay,4,1,20,0);
}
x=dbObjectPositionX(1);
y=dbObjectPositionY(1);
z=dbObjectPositionZ(1);
if(dis<1.5 && dbWrapValue(ay-dbCameraAngleY(1))>170)
dbSetCameraToFollow(1,x,y,z,ay,-4,1,10,0);
else
dbSetCameraToFollow(1,x,y,z,ay,4,1,80,0);
dbYRotateObject(1,ay);
dbPointCamera(1,x,y+0.7,z);
}
float distance(float x,float y, float z,float nx, float ny, float nz)
{
float ox,oy,oz,ret;
ox=x-nx;
oy=y-ny;
oz=z-nz;
ox=ox*ox;
oy=oy*oy;
oz=oz*oz;
ret=dbSQRT(ox+oy+oz);
return ret;
}
Any one got an idea?
For idea about spyro , just youtube it.
They asked me for a proof.
Now i am making one........