Hi ReiKumar,
I hope that i understand your question right.
If you just want to check for a collision between Object you may examine the following code:
// Collision Detection
// Author: Yerrel
// www.binary-coder.com
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.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 );
// Create Camera 1 and set background color to be blue
dbMakeCamera(1);
dbColorBackdrop(1, dbRgb(0, 0, 150));
//Move the camera back
dbPositionCamera(1, 0, 0, -25);
// Create a Sphere and a Cube and Set its color
dbMakeObjectSphere(1, 4);
dbColorObject(1, dbRgb(255, 0, 0));
dbMakeObjectCube(2, 2); // Cube will be the wall..
dbColorObject(2, dbRgb(0, 0, 255));
// Scale the obejcts
dbScaleObject(1, 70, 70, 10);
dbScaleObject(2, 20, 400, 40);
// Position the objects
dbPositionObject(1, 15, 0, 0);
dbPositionObject(2, -18, 0, 0);
// Declare the position variables
float x = 0.0, y = 0.0, z = 0.0, ax = -0.2;
// Enter Mainloop
// our main loop
while ( LoopGDK ( ) )
{
// Check to if Object 1(Sphere) is colliding with Object 2
// And check if the position of the Sphere is inside the visible area of the screen.
if(dbObjectHit(1, 2) || dbObjectPositionX(1) > 15)
{
// If Collision or the Sphere is out of display then reverse the moving direction.
ax = -ax;
if(dbObjectPositionX(1) <15 )
dbColorObject(2, dbRgb(dbRnd(255), dbRnd(255), dbRnd(255)));
}
// Change the color of the Sphere when it rebound.
if(dbObjectPositionX(1) > 15)
dbColorObject(1, dbRgb(dbRnd(255), dbRnd(255), dbRnd(255)));
//Update the X-position
x = x + ax;
dbPositionObject(1, x, y, z);
// update the screen
dbSync ( );
}
// return back to windows
return;
}
Hope that this is what you mean.
MSI K8T NEO-2 F2.0, 8XAGP, 2x512Mb Dual Channel... Dark GDK..... http://www.binary-coder.com