2024-02-24 16:16:09 +00:00
|
|
|
function on_init()
|
|
|
|
local cube = world:request_res("assets/cube-texture-embedded.gltf")
|
|
|
|
print("Loaded textured cube")
|
2024-02-24 19:32:06 +00:00
|
|
|
|
|
|
|
local pos = Transform.from_translation(Vec3.new(0, 0, -8.0))
|
|
|
|
|
2024-02-24 20:27:01 +00:00
|
|
|
local e = world:spawn(pos, cube)
|
2024-02-24 19:32:06 +00:00
|
|
|
print("spawned entity " .. tostring(e))
|
2024-02-25 22:06:53 +00:00
|
|
|
|
|
|
|
local action_handler_tbl = {
|
|
|
|
layouts = { 0 },
|
|
|
|
actions = {
|
|
|
|
MoveForwardBackward = "Axis",
|
|
|
|
MoveLeftRight = "Axis",
|
|
|
|
MoveUpDown = "Axis",
|
|
|
|
LookLeftRight = "Axis",
|
|
|
|
LookUpDown = "Axis",
|
|
|
|
LookRoll = "Axis",
|
|
|
|
},
|
|
|
|
mappings = {
|
|
|
|
{
|
|
|
|
layout = 0,
|
|
|
|
binds = {
|
|
|
|
MoveForwardBackward = {
|
|
|
|
"key:w=1.0", "key:s=-1.0"
|
|
|
|
},
|
|
|
|
MoveLeftRight = {
|
|
|
|
"key:a=-1.0", "key:d=1.0"
|
|
|
|
},
|
|
|
|
MoveUpDown = {
|
|
|
|
"key:c=1.0", "key:z=-1.0"
|
|
|
|
},
|
|
|
|
LookLeftRight = {
|
|
|
|
"key:left=-1.0", "key:right=1.0",
|
|
|
|
"mouse:axis:x"
|
|
|
|
},
|
|
|
|
LookUpDown = {
|
|
|
|
"key:up=-1.0", "key:down=1.0",
|
|
|
|
"mouse:axis:y",
|
|
|
|
},
|
|
|
|
LookRoll = {
|
|
|
|
"key:e=-1.0", "key:q=1.0",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
local handler = ActionHandler.new(action_handler_tbl)
|
|
|
|
world:add_resource(handler)
|
2024-01-07 05:57:19 +00:00
|
|
|
end
|
|
|
|
|
2024-02-24 16:16:09 +00:00
|
|
|
--[[ function on_first()
|
2024-01-07 05:57:19 +00:00
|
|
|
print("Lua's first function was called")
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_pre_update()
|
|
|
|
print("Lua's pre-update function was called")
|
2024-01-13 16:52:20 +00:00
|
|
|
end ]]
|
2024-01-07 05:57:19 +00:00
|
|
|
|
|
|
|
function on_update()
|
2024-02-19 16:27:49 +00:00
|
|
|
---@type number
|
2024-02-18 00:08:11 +00:00
|
|
|
local dt = world:resource(DeltaTime)
|
|
|
|
|
|
|
|
world:view(function (t)
|
2024-02-19 22:57:48 +00:00
|
|
|
t:translate(0, 0.5 * dt, 0)
|
2024-01-13 16:52:20 +00:00
|
|
|
|
2024-02-18 00:08:11 +00:00
|
|
|
return t
|
|
|
|
end, Transform)
|
2024-02-25 22:06:53 +00:00
|
|
|
|
|
|
|
--local input = world:resource(Input)
|
|
|
|
--input.
|
2024-01-07 05:57:19 +00:00
|
|
|
end
|
|
|
|
|
2024-01-13 16:52:20 +00:00
|
|
|
--[[ function on_post_update()
|
2024-01-07 05:57:19 +00:00
|
|
|
print("Lua's post-update function was called")
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_last()
|
|
|
|
print("Lua's last function was called")
|
2024-01-13 16:52:20 +00:00
|
|
|
end ]]
|