numofplanets = irandom_range(8, 20)
show_debug_message(string(numofplanets))
for (i=0; i<numofplanets; i+=1) {
planetx[i] = 0
planety[i] = 0
planetr[i] = 0
}
for (i=0; i<numofplanets; i+=1) {
do {
collide = false
planetx[i] = irandom_range(0, 640)
planety[i] = irandom_range(0, 480)
planetr[i] = random_range(0.125, 1)
if planetx[i] + (planetr[i] * 60) >= 635 {
planetx[i] = 635 - (planetr[i] * 60)
}
if planetx[i] - (planetr[i] * 60) <= 5 {
planetx[i] = 5 + (planetr[i] * 60)
}
if planety[i] + (planetr[i] * 60) >= 475 {
planety[i] = 475 - (planetr[i] * 60)
}
if planety[i] - (planetr[i] * 60) <= 5 {
planety[i] = 5 + (planetr[i] * 60)
}
for (j=0; j<numofplanets; j+=1) {
if i != j {
if ((planetx[i] + (planetr[i] * 40)) >= (planetx[j] - (planetr[j] * 40))) && ((planetx[i] + (planetr[i] * 40)) <= (planetx[j] + (planetr[j] * 40))) {
if ((planety[i] + (planetr[i] * 40)) >= (planety[j] - (planetr[j] * 40))) && ((planety[i] + (planetr[i] * 40)) <= (planety[j] + (planetr[j] * 40))) {
collide = true
}
}
}
}
}
until (collide = false)
}
in planetr[] the r is radius, the sprite which is drawn is 80x80, centered, and is drawn with draw_sprite_ext, scaled using planetr[]For some reason the "planets" still overlap each other... can someone tell me why?
Edited by Andriko, 18 August 2012 - 01:07 AM.











