This repository has been archived on 2025-02-14. You can view files and clone it, but cannot push or open issues or pull requests.
quack-twn/data/scripts/game.lua

33 lines
944 B
Lua

local FONT = "fonts/Lunchtype21_Regular.ttf"
local Vector3 = require "vector3"
local player = require "classes.player"
local function Vector2(x, y)
if y == nil then
return {x = x, y = x}
end
return {x = x, y = y}
end
function game_tick()
-- ctx.initialization_needed is true first frame and every time dynamic reload is performed
if ctx.initialization_needed then
-- ctx.udata persists on reload
ctx.udata = {
capture = false
}
end
ctx.mouse_capture = ctx.udata.capture
input_action{name="toggle_mouse", control="ESCAPE"}
if input_action_just_pressed{name = "toggle_mouse"} then
ctx.udata.capture = not ctx.udata.capture
end
player:tick(ctx)
draw_billboard{position = Vector3(0, 0, 3), size = Vector2(1, 1), texture = "images/duck.png"}
draw_text{position = Vector2(0), string = "vel: " .. tostring(player.velocity), font = FONT}
end