make it so the colored blocks in this game are gray "-- tiny builder game in pico-8

-- define block size and colors
block_size = 8
colors = {8, 9, 10, 11} -- different colors for blocks
green_sprite_idx = 2 -- sprite index for green block
golden_color = 10 -- color for golden snowflakes

-- grid dimensions
grid_width = 15
grid_height = 15

-- player position (cursor)
player_x = 0
player_y = 0

-- grid to store blocks
blocks = {}

-- player score and game state
score = 0
time_limit = 60 * 5 -- 5 minutes in seconds
start_time = time()
game_over = false
game_won = false

function init_blocks()
    for x=1,grid_width do
        blocks[x] = {}
        for y=1,grid_height do
            blocks[x][y] = 0
        end
    end
end

-- initialize game state
function _init()
    init_blocks()
end

-- update game state
function _update()
    if game_over or game_won then
        return
    end

    -- check time
    local elapsed_time = time() - start_time
    if elapsed_time > time_limit then
        if score < 8000 then
            game_over = true
        end
    end

    -- check win condition
    if score >= 8000 then
        game_won = true
    end

    -- move cursor
    if (btnp(0)) then player_x = max(0, player_x - 1) end
    if (btnp(1)) then player_x = min(grid_width - 1, player_x + 1) end
    if (btnp(2)) then player_y = max(0, player_y - 1) end
    if (btnp(3)) then player_y = min(grid_height - 1, player_y + 1) end

    -- place block
    if (btnp(4)) then
        if blocks[player_x + 1][player_y + 1] == 0 then
            if rnd() < 0.25 then
                blocks[player_x + 1][player_y + 1] = green_sprite_idx
            else
                blocks[player_x + 1][player_y + 1] = colors[flr(rnd(#colors)) + 1]
            end
            check_for_scoring()
        end
    end

    -- erase block
    if (btnp(5)) then
        if blocks[player_x + 1][player_y + 1] ~= 0 then
            blocks[player_x + 1][player_y + 1] = 0
        end
    end
end

-- check for 3-in-a-row green blocks to score points
function check_for_scoring()
    -- horizontal
    for y=1,grid_height do
        for x=1,grid_width-2 do
            if blocks[x][y] == green_sprite_idx and blocks[x+1][y] == green_sprite_idx and blocks[x+2][y] == green_sprite_idx then
                score += 300
                blocks[x][y], blocks[x+1][y], blocks[x+2][y] = 0, 0, 0
            end
        end
    end

    -- vertical
    for x=1,grid_width do
        for y=1,grid_height-2 do
            if blocks[x][y] == green_sprite_idx and blocks[x][y+1] == green_sprite_idx and blocks[x][y+2] == green_sprite_idx then
                score += 300
                blocks[x][y], blocks[x][y+1], blocks[x][y+2] = 0, 0, 0
            end
        end
    end

    -- diagonal (down-right)
    for x=1,grid_width-2 do
        for y=1,grid_height-2 do
            if blocks[x][y] == green_sprite_idx and blocks[x+1][y+1] == green_sprite_idx and blocks[x+2][y+2] == green_sprite_idx then
                score += 300
                blocks[x][y], blocks[x+1][y+1], blocks[x+2][y+2] = 0, 0, 0
            end
        end
    end

    -- diagonal (up-right)
    for x=1,grid_width-2 do
        for y=3,grid_height do
            if blocks[x][y] == green_sprite_idx and blocks[x+1][y-1] == green_sprite_idx and blocks[x+2][y-2] == green_sprite_idx then
                score += 300
                blocks[x][y], blocks[x+1][y-1], blocks[x+2][y-2] = 0, 0, 0
            end
        end
    end
end

-- draw the game
function _draw()
    cls()

    if game_over then
        print_centered("game over", 64, 40, 8)
        return
    elseif game_won then
        print_centered("you win", 64, 40, 10)
        scatter_snowflakes()
        return
    end
    
    -- draw blocks
    for x=1,grid_width do
        for y=1,grid_height do
            local bx, by = (x - 1) * block_size, (y - 1) * block_size
            if blocks[x][y] > 0 then
                if blocks[x][y] == green_sprite_idx then
                    spr(green_sprite_idx, bx, by)
                else
                    rectfill(bx, by, bx + block_size - 1, by + block_size - 1, blocks[x][y])
                end
            end
        end
    end

    -- draw cursor (outline of the currently selected block)
    rect(player_x * block_size, player_y * block_size, (player_x + 1) * block_size - 1, (player_y + 1) * block_size - 1, 7)

    -- draw score and time
    print("score: "..tostr(score), 1, 1, 7)
    print("time: "..to_minutes(time_limit - (time() - start_time)), 1, 10, 7)
end

-- print text centered on the screen
function print_centered(text, x, y, color)
    local length = #text * 4
    print(text, x - length / 2, y, color)
end

-- convert seconds to a mm:ss format
function to_minutes(sec)
    return flr(sec/60)..":"..sub("0"..flr(sec%60), -2)
end

-- scatter golden snowflakes across the screen
function scatter_snowflakes()
    for i = 1, 50 do
        circfill(rnd(128), rnd(128), 1, golden_color)
    end
end"