1>/* Graphics Not Rendered in HTML */
#define APPLES_NUM 128
I64 x[APPLES_NUM],y[APPLES_NUM],
cur_apple,cur_dist;
Bool trigger;
U0 DrawIt(CTask *,CDC *dc)
{
I64 i,best_dist=I64_MAX,best_apple=0;
dc->flags|=DCF_LOCATE_NEAREST;
dc->cur_x=ms.pos.x;
dc->cur_y=ms.pos.y;
dc->cur_z=0;
for (i=0;i);
if (dc->nearest_dist<=best_dist) {
//Distance to nearest pix, squared
//Sqrt() is expensive so we work with distance squared.
best_dist=dc->nearest_dist;
best_apple=i;
}
}
if (trigger) {
cur_apple=best_apple;
cur_dist=best_dist;
trigger=FALSE;
}
GrPrint(dc,FONT_WIDTH,FONT_HEIGHT,"Dist Squared:%d",cur_dist);
}
U0 Pick()
{
I64 i,msg_code,arg1,arg2,delta_x,delta_y;
for (i=0;idraw_it=&DrawIt;
Fs->win_inhibit=WIG_TASK_DFT-WIF_SELF_FOCUS-WIF_SELF_BORDER;
try {
while (TRUE) {
if (GetMsg(&arg1,&arg2,1<