couch-rust/main.lua

25 lines
667 B
Lua
Raw Normal View History

2022-04-09 12:42:18 -05:00
print("Hello from a lua script!")
2022-04-11 16:14:09 -05:00
2022-04-16 20:54:14 -05:00
local roll_x = 0.0
2022-04-15 20:15:48 -05:00
function couch.init()
2022-04-11 16:14:09 -05:00
print("Hello from \"init\"")
end
2022-04-15 20:15:48 -05:00
function couch.update(delta)
2022-04-15 17:51:26 -05:00
local transform = couch.root:find_node("cube"):get_transform()
2022-04-16 20:54:14 -05:00
transform.rotation[2] = transform.rotation[2] + delta * roll_x
2022-04-15 17:51:26 -05:00
transform.rotation[1] = transform.rotation[1] - delta * 0.3
couch.root:find_node("cube"):set_transform(transform)
2022-04-11 16:14:09 -05:00
end
2022-04-15 20:15:48 -05:00
2022-04-16 20:54:14 -05:00
function couch.keypressed(scancode)
2022-04-21 11:10:12 -05:00
if scancode == couch.KEY_A then roll_x = 1.0 end
if scancode == couch.KEY_D then roll_x = -1.0 end
2022-04-16 20:54:14 -05:00
end
2022-04-15 20:15:48 -05:00
function couch.keyreleased(scancode)
if scancode == couch.KEY_A or scancode == couch.KEY_D then roll_x = 0.0 end
2022-04-15 20:15:48 -05:00
end