boot.lua 633 B

12345678910111213141516171819202122232425262728293031
  1. -- Copyright (c) 2012-2026 Daniele Bartolini et al.
  2. -- SPDX-License-Identifier: MIT
  3. world = world or nil
  4. camera_unit = camera_unit or nil
  5. function init()
  6. -- Create world and camera
  7. world = Device.create_world()
  8. camera_unit = World.spawn_unit(world, "core/units/camera")
  9. end
  10. function update(dt)
  11. -- Advance the simulation
  12. World.update(world, dt)
  13. -- Stop the engine when the 'ESC' key is released
  14. if Keyboard.released(Keyboard.button_id("escape")) then
  15. Device.quit()
  16. end
  17. end
  18. function render(dt)
  19. -- Render the world
  20. Device.render(world, camera_unit)
  21. end
  22. function shutdown()
  23. -- Cleanup
  24. Device.destroy_world(world)
  25. end