I'm trying to plot a circular X/Y graph using 2 for loops, but can't figure out the algorithm to make it circular instead of squared.
I currently have 2 nested for loops but this makes a 5 by 5 square. Is there anything I can add that would make the box circular instead? Preferabbly with a slight randomisation.
For some context I'm trying to learn the basics of procedural generation, and am trying to implement biome types into a 2d map I am randomly generating.
Thank you!
//my code has a for loop which runs the whole sequence several times
for ($i=0; $i<$x; $i++) {
// select a random tile from the database to use as the center of the grid
${'qt'. $i} = $db->query("SELECT x,y,level,type,biomecenter FROM bmmap WHERE biomecenter=0 ORDER BY RAND() LIMIT 1");
${'rt'. $i} = ${'qt'. $i}->fetch_assoc();
// draw the grid around the center tile
for ($tx=${'rt'. $i}['x']-5; $tx<=${'rt'. $i}['x']+5; $tx++) {
for ($ty=${'rt'. $i}['y']-5; $ty<=${'rt'. $i}['y']+5; $ty++) {
// plot the square
}
}
}