I have a robot, and if you hover the mouse over the robot a small laser object will appear (just to test so it's working). However, if you move the camera around it totally messes up the boundaries so if you hover your mouse over the robot it will no longer display the laser (however, if you hover your mouse over some other place in the window it will display the laser because that's where the program thinks the robot is located). So, after i've moved the camera around, how do i make the program know that the position of the robot is different too?
#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 );
dbLoadObject("robot.3DS", 1);
dbLoadObject("laser.3DS", 2);
dbHideObject(2);
dbPositionObject(1, 20, -10, 50);
float x = 20;
float y = -10;
float z = 50;
int laserShot = 50;
float robotLeft = x + 230;
float robotRight = x + 350;
float robotTop = y + 80;
float robotBottom = y + 200;
float cameraX = 20;
float cameraY = 100;
float cameraZ = -50;
dbPositionCamera(cameraX, cameraY, cameraZ);
// our main loop
dbXRotateCamera(70);
while ( LoopGDK ( ) )
{
if (dbMouseX() >= robotLeft && dbMouseX() <= robotRight && dbMouseY() >= robotTop && dbMouseY() <= robotBottom)
{
dbShowObject(2);
}
else
{
dbHideObject(2);
}
if (dbDownKey())
{
cameraZ = cameraZ -5;
dbPositionCamera (cameraX, cameraY, cameraZ);
}
if (dbUpKey())
{
cameraZ = cameraZ +5;
dbPositionCamera (cameraX, cameraY, cameraZ);
}
if (dbRightKey())
{
cameraX = cameraX +5;
dbPositionCamera (cameraX, cameraY, cameraZ);
}
if (dbLeftKey())
{
cameraX = cameraX -5;
dbPositionCamera (cameraX, cameraY, cameraZ);
}
dbSync ( );
}
// return back to windows
return;
}