Yeah it was messed up with the 2d and 3d space thingy like jezza said, when i positioned an extra object and checked if the first object was at the same position it worked. However i've run into a new problem, how do i move my object to location specified by the mouse click? I tried positioning an object at the mouse click location (if that worked i could just hide that object and check if the first object was at the same location). But i assume it captures where the mouse is in 2d as well because the object is not positioned where i click with my mouse. What should i do to be able to move an object to a position specified by the mouse?
#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 );
dbMaximizeWindow();
dbLoadObject("tank.x", 1);
int tank = 1;
dbLoadObject("tank.x", 2);
int tank2 = 2;
dbPositionObject(2, 0, 300, 0);
dbRotateCamera(0, 0, 0);
dbPositionCamera(0, 0, -2000);
// our main loop
while ( LoopGDK ( ) )
{
if (dbLeftKey())
{
dbMoveObjectLeft(tank, 1);
}
if (dbRightKey())
{
dbMoveObjectRight(tank, 1);
}
if (dbDownKey())
{
dbMoveObjectDown(tank, 1);
}
if (dbUpKey())
{
dbMoveObjectUp(tank, 1);
}
if (dbObjectPositionX(tank) >= dbObjectPositionX(tank2)-5 && dbObjectPositionX(tank) <= dbObjectPositionX(tank2) +5)
{
dbText(250, 250, "X Position matches.");
}
if (dbObjectPositionY(tank) >= dbObjectPositionY(tank2) -5 && dbObjectPositionY(tank) <= dbObjectPositionY(tank2) +5)
{
dbText(250, 300, "Y Position matches.");
}
if (dbMouseClick() == 2)
{
dbPositionObject(tank2, dbMouseX(), dbMouseY(), 0);
}
// update the screen
dbSync ( );
}
// return back to windows
return;
}