ORIGIN = { x = 320, y = 180 }
RADIUS = 48
offset = { x = 0, y = 0 }
angle = 0

function game_tick()
    if ctx.udata == nil then
        ctx.udata = {
            frame_count = 0,
            nest = {
                frame_count = 0,
            },
            arr = { [0] = 0 },
        }
    end

    draw_text {
        string = tostring(ctx.udata.frame_count),
        position = { x = 0, y = 0 },
        font = "/fonts/kenney-pixel.ttf",
    }

    draw_text {
        string = tostring(ctx.udata.nest.frame_count),
        position = { x = 0, y = 14 },
        font = "/fonts/kenney-pixel.ttf",
    }

    draw_text {
        string = tostring(ctx.udata.arr[0]),
        position = { x = 0, y = 28 },
        font = "/fonts/kenney-pixel.ttf",
    }

    input_action {
        name = "press",
        control = "A"
    }

    draw_sprite {
        texture = "/assets/title.png",
        rect = {
            x = 320 - (320 / 2),
            y = 180 - (128 / 2),
            w = 320,
            h = 128,
        },
    }

    if input_action_pressed { name = "press" } then
        draw_text {
            string = "it never happened",
            position = offset,
            font = "/fonts/kenney-pixel.ttf",
        }
    end

    ctx.udata.frame_count = ctx.udata.frame_count + 1
    ctx.udata.nest.frame_count = ctx.udata.nest.frame_count + 1
    ctx.udata.arr[0] = ctx.udata.arr[0] + 1

    offset.x = ORIGIN.x + (math.cos(angle) * RADIUS)
    offset.y = ORIGIN.y + (math.sin(angle) * RADIUS)
    angle = angle + 0.1
end