10PRINT Banner

import "CoreLibs/graphics"

local gfx<const> = playdate.graphics
local dsp<const> = playdate.display

local spacing<const> = 10

local xCount
local yCount

local x = 0
local y = 0
local invert = false

function setup()
    dsp.setScale(2)
    xCount = dsp.getWidth() / spacing
    yCount = dsp.getHeight() / spacing
end

setup()

function playdate.update()
    if math.random() < 0.5 then
        gfx.drawLine(x, y, x + spacing, y + spacing)
    else
        gfx.drawLine(x, y + spacing, x + spacing, y)
    end

    x = x + spacing

    if x > dsp.getWidth() then
        x = 0
        y = y + spacing

        if y >= dsp.getHeight() then
            y = 0
            invert = not invert

            dsp.setInverted(invert)
            gfx.clear()
        end
    end
end

Preview