81 lines
2.1 KiB
Lua
81 lines
2.1 KiB
Lua
function on_init()
|
|
local cube = world:request_res("assets/cube-texture-embedded.gltf")
|
|
print("Loaded textured cube")
|
|
|
|
local pos = Transform.from_translation(Vec3.new(0, 0, -8.0))
|
|
|
|
local e = world:spawn(pos, cube)
|
|
print("spawned entity " .. tostring(e))
|
|
|
|
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)
|
|
end
|
|
|
|
--[[ function on_first()
|
|
print("Lua's first function was called")
|
|
end
|
|
|
|
function on_pre_update()
|
|
print("Lua's pre-update function was called")
|
|
end ]]
|
|
|
|
function on_update()
|
|
---@type number
|
|
local dt = world:resource(DeltaTime)
|
|
|
|
world:view(function (t)
|
|
t:translate(0, 0.5 * dt, 0)
|
|
|
|
return t
|
|
end, Transform)
|
|
|
|
--local input = world:resource(Input)
|
|
--input.
|
|
end
|
|
|
|
--[[ function on_post_update()
|
|
print("Lua's post-update function was called")
|
|
end
|
|
|
|
function on_last()
|
|
print("Lua's last function was called")
|
|
end ]] |