Index: apps/plugins/wormlet.c =================================================================== --- apps/plugins/wormlet.c (revision 22667) +++ apps/plugins/wormlet.c (working copy) @@ -830,22 +830,23 @@ the entire food lies within the FIELD */ x = rb->rand() % (FIELD_RECT_WIDTH - food_size); y = rb->rand() % (FIELD_RECT_HEIGHT - food_size); - + collisionDetected = false; /* Ensure that the new food doesn't collide with any existing foods or arghs. - If one or more corners of the new food hit any existing + If the new food hit any existing argh or food a collision is detected. */ - collisionDetected = - food_collision(x , y ) >= 0 || - food_collision(x , y + food_size - 1) >= 0 || - food_collision(x + food_size - 1, y ) >= 0 || - food_collision(x + food_size - 1, y + food_size - 1) >= 0 || - argh_collision(x , y ) >= 0 || - argh_collision(x , y + food_size - 1) >= 0 || - argh_collision(x + food_size - 1, y ) >= 0 || - argh_collision(x + food_size - 1, y + food_size - 1) >= 0; + for (i=0; irand() % (FIELD_RECT_WIDTH - argh_size); y = rb->rand() % (FIELD_RECT_HEIGHT - argh_size); - + collisionDetected = false; /* Ensure that the new argh doesn't intersect with any existing foods or arghs. - If one or more corners of the new argh hit any existing + If the new argh hit any existing argh or food an intersection is detected. */ - collisionDetected = - food_collision(x , y ) >= 0 || - food_collision(x , y + argh_size - 1) >= 0 || - food_collision(x + argh_size - 1, y ) >= 0 || - food_collision(x + argh_size - 1, y + argh_size - 1) >= 0 || - argh_collision(x , y ) >= 0 || - argh_collision(x , y + argh_size - 1) >= 0 || - argh_collision(x + argh_size - 1, y ) >= 0 || - argh_collision(x + argh_size - 1, y + argh_size - 1) >= 0; + for (i=0; i