if(dbMouseClick() == 1)
{
for(int i=0;i<units.size();i++)
{
int cx = g_cameraX+dbMouseX();
int cy = g_cameraY+dbMouseY();
if(cx >= units.at(i).x+g_cameraX && cx <= units.at(i).x+g_cameraX+dbGetImageWidth(units.at(i).imageID))
{
g_selected_object=i;
break;
}
}
}
if(g_selected_object != 0)
{
int ux = units.at(g_selected_object).x + g_cameraX;
int uy = units.at(g_selected_object).y + g_cameraY + dbGetImageHeight(units.at(g_selected_object).imageID) + 3;
dbLine(ux,uy,ux+dbGetImageWidth(units.at(g_selected_object).imageID),uy);
}
Im trying to cycle through units to see if the mouse has clicked on one of them.
cameraX and cameraY is the off set of the map which the is used to set where the camera is looking at. so i use this to also see where units are.
can anyone see whats is going wrong here because when I click on any units they arnt being selected
2.0Gh AM2 Processor, 9800GT, 2Gb Ram