theagg
Try this to see if it does most of what you want
// 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"
int Floor = 100;
int Ball = 101;
int I = 0 ;
int Box;
int MaxBoxes = 5;
int BoxTimer[MaxBoxes];
void MoveBall(int Ball);
float Distance (int Obj1,int Obj2);
// 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 );
dbRandomize(dbTimer());
// randomly place 5 boxes
for ( Box=1; Box <= MaxBoxes;Box++){
dbMakeObjectBox(Box, 2,2,2);
dbPositionObject(Box, dbRnd(50)-25, 1,dbRnd(50)-25);
}
// create ball
dbMakeObjectSphere(Ball,2);
dbPositionObject(Ball,0,2,0);
dbPositionCamera(0,25,25,-20);
dbPointCamera(0,0,0,0);
// our main loop
while ( LoopGDK ( ) ){
MoveBall(Ball);
for ( Box=1; Box <= MaxBoxes;Box++){
if (Distance(Ball,Box)< 10.0){
BoxTimer[Box] = 0;
dbColorObject(Box,dbRGB(0,0,0));
}
else {
BoxTimer[Box]++;
dbColorObject(Box,dbRGB(255,0,0));
}
}
// update the screen
for ( Box=1; Box <= MaxBoxes;Box++){
dbText(10,20*Box,"Box Timer");dbText(100,20*Box, dbStr(Box));dbText(130,20*Box,dbStr(BoxTimer[Box]));
}
dbSync ( );
}
// return back to windows
return;
}
void MoveBall(int Ball){
float newX = dbObjectPositionX(Ball);
float newZ = dbObjectPositionZ(Ball);
newX = newX + (dbRnd(10)-5.0)/10.0;
newZ = newZ + (dbRnd(10)-5.0)/10.0;
dbPositionObject(Ball,newX,1.0,newZ);
}
float Distance (int Obj1, int Obj2){
float x1 = dbObjectPositionX(Obj1);
float y1 = dbObjectPositionY(Obj1);
float z1 = dbObjectPositionZ(Obj1);
float x2 = dbObjectPositionX(Obj2);
float y2 = dbObjectPositionY(Obj2);
float z2 = dbObjectPositionZ(Obj2);
dbMakeVector3(1);
dbSetVector3 ( 1, x1 - x2, y1 - y2, z1 - z2 );
float length_vector = dbAbs(dbLengthVector3( 1 ));
dbDeleteVector3 ( 1 );
return length_vector;
}
Codger
System
PIV 2.8 MZ 512 Mem
FX 5600 256 mem