AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
Basically my code kinda works but not really. I'm so sorry, I keep asking questions. Just please help me on this one:
#1: I want to make only two circles visible at a time, so once three exist, delete the oldest one.
#2: It does check for overlap correctly. Keep in mind that the circles have a radius of 40. I don't want to just make sure that the centers don't overlap, I want the BORDERS to not overlap. I want it so that all of the borders of all of the circles are at least touching one other border, but make sure that the borders don't go inside of the empty space in another circle.
import "CoreLibs/graphics"
import "CoreLibs/object"
import "CoreLibs/sprites"
import "CoreLibs/nineslice"
import "CoreLibs/timer"
import "CoreLibs/frameTimer"
import "config"
import "core/definitions"
import "core/cotton/all"
import "scripts/index"
import "core/lieb/all"
import "core/CoreGame"
bpm = 60
lastX = math.random(80, 320)
lastY = math.random(80, 160)
circles = {}
function addCircle()
x = lastX + math.random(-40, 40)
y = lastY + math.random(-40, 40)
-- Check if the new circle would overlap with any existing circles
for i, c in ipairs(circles) do
distance = math.sqrt((x - c.x) ^ 2 + (y - c.y) ^ 2)
if distance < 80 then
x = lastX
y = lastY
break
end
end
if #circles >= 3 then
circles[1]:destroy()
table.remove(circles, 1)
end
circle = playdate.graphics.drawCircleAtPoint(x, y, 40)
table.insert(circles, circle)
lastX = x
lastY = y
end
beatTimer = playdate.timer.performAfterDelay(60000 / bpm, addCircle)
beatTimer.repeats = true
function playdate.update()
input.update()
playdate.timer.updateTimers()
end