<= $radius; $i++) {
for ($j=0; $j <= $radius; $j++) {
$x = $curr_x + $j;
$y = $curr_y + $i;
if (($x <= $length && $x > 0) && ($y <= $height && $y > 0)) {
$coordinats[] = ['x' => $x, 'y' => $y];
}
$x = $curr_x - $j;
$y = $curr_y - $i;
if (($x <= $length && $x > 0) && ($y <= $height && $y > 0)) {
$coordinats[] = ['x' => $x, 'y' => $y];
}
$x = $curr_x - $j;
$y = $curr_y + $i;
if (($x <= $length && $x > 0) && ($y <= $height && $y > 0)) {
$coordinats[] = ['x' => $x, 'y' => $y];
}
$x = $curr_x + $j;
$y = $curr_y - $i;
if (($x <= $length && $x > 0) && ($y <= $height && $y > 0)) {
$coordinats[] = ['x' => $x, 'y' => $y];
}
}
}
function checkXY($x, $y) { if (($x <= $length && $x > 0) && ($y <= $height && $y > 0)) { $coordinats[] = ['x' => $x, 'y' => $y]; } } for ($i=0; $i <= $radius; $i++) { for ($j=0; $j <= $radius; $j++) { checkXY($curr_x + $j, $curr_y + $i); checkXY($curr_x - $j, $curr_y - $i); checkXY($curr_x - $j, $curr_y + $i); checkXY($curr_x + $j, $curr_y - $i); } }
Обсуждают сегодня