## Inspiration

Inspired by mini games

## What it does

function love.load() math.randomseed(os.time()) screen = {} screen.w = 800 screen.h = 600 love.window.setMode(screen.w, screen.h)

``````balls = {}
mouse = {}
reset = 0
score = 0
colorcount = 0
``````

end

function love.mousereleased(x,y,button) reset = 0 return reset end

function love.update(dt) if math.random() < 0.02 then local ball = {} ball.x = math.random(50, 700) ball.y = 0 ball.r = 20 ball.t = math.random(3, 20) ball.v = math.random(2, 3) ball.h = 0

``````    ball.cn = math.random(1,5)
if ball.cn == 1 then
ball.c = {247/255, 173/255, 173/255}
elseif ball.cn == 2 then
ball.c = {242/255, 200/255, 155/255}
elseif ball.cn == 3 then
ball.c = {183/255, 251/255, 255/255}
elseif ball.cn == 4 then
ball.c = {194/255, 237/255, 163/255}
elseif ball.cn == 5 then
ball.c = {228/255, 193/255, 242/255}
end

table.insert(balls, ball)
end

for i = #balls, 1, -1 do
local ball = balls[i]

-- before the ball touches the ground
if (ball.y + ball.r) < (screen.h - 10) then
ball.y = ball.y + ball.v
end

if ball.t <= 0 then
table.remove(balls, i)
score = score + 1
end
end

if (love.mouse.isDown(1) and reset == 0) then
reset = 1
first = 1
for i = #balls, 1, -1 do
local ball_1 = balls[i]
mouse.x, mouse.y = love.mouse.getPosition()
mousedist = math.sqrt((ball_1.x - mouse.x)^2 + (ball_1.y - mouse.y)^2)
if mousedist < ball_1.r then
ball_1.t = ball_1.t - 1
for j = #balls, 1, -1 do
local ball_2 = balls[j]
if (i ~= j and ball_2.cn == ball_1.cn) then
ball_2.t = ball_2.t - 1
elseif (i ~= 1 or i ~= #balls or ball_2.cn ~= ball_1.cn) then
for k = #balls, 1, -1 do
local ball_3 = balls[k]
ball_3.h = 0
end
end
end
end
end
end

-- for i = 1, #balls, 1 do
-- local ball_1 = balls[i]
-- for j = 1, i, 1 do
-- local ball_2 = balls[j]
-- -- before the ball touches the ground
-- if (ball_1.y + ball_1.r) < (screen.h - 10) then
-- -- find distance between 2 balls
-- if i ~= j then
-- dist = math.sqrt((ball_1.x - ball_2.x)^2 + (ball_1.y - ball_2.y)^2)

-- if dist <= (ball_1.r + ball_2.r) then
-- ball_1_vnew = ball_2.v
-- else
-- ball_1_vnew = ball_1.v
-- end
-- else
-- ball_1_vnew = ball_1.v
-- end
-- -- give speed
-- ball_1.y = ball_1.y + ball_1_vnew
-- end
-- end
-- end
``````

end

function love.draw() love.graphics.setBackgroundColor(0.5, 0.7, 0.7)

``````for i=#balls, 1, -1 do
local ball = balls[i]
love.graphics.setColor(ball.c)
love.graphics.circle("fill", ball.x, ball.y, ball.r)
love.graphics.setColor(0,0,0)
love.graphics.printf(ball.t, ball.x - ball.r/2, ball.y - ball.r/2, ball.r, "center")
if ball.h == 1 then
love.graphics.circle("line", ball.x, ball.y, ball.r + 4)
end
end

love.graphics.print('SCORE: ' .. score, 10, 10)
love.graphics.print('COLORCOUNT: ' .. colorcount, 10, 10)
``````

end

## What's next for Color Countdown

Fixing some bugs, adding more features to improve game-play and level of interest