quack2/data/scripts/game.lua

38 lines
1.1 KiB
Lua
Raw Normal View History

2025-02-13 21:44:00 +00:00
local player = require "classes.player"
local util = require "util"
local Vector3 = require "types.vector3"
2025-02-14 12:17:05 +00:00
local Signal = require("types.signal")
2025-02-13 21:44:00 +00:00
2025-02-13 19:19:52 +00:00
-- called every frame, with constant delta time
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
2025-02-13 21:44:00 +00:00
ctx.udata = {
capture = false
}
2025-02-14 12:17:05 +00:00
player.ThrowPressed:connect(
function (position, direction)
print(position, " ", direction)
end
)
2025-02-13 19:19:52 +00:00
end
2025-02-13 21:44:00 +00:00
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_camera{position = Vector3(0, 1, 0), direction = Vector3.FORWARD}
-- draw ground
local q = util.create_plane_quad(Vector3(0, 0, 0), Vector3.UP, 10)
local params = {
texture = "images/measure001a.png",
texture_region = { x = 0, y = 0, w = 512, h = 512 },
}
draw_quad(util.merge(q, params))
2025-02-13 19:19:52 +00:00
end