game.lua 651 B

1234567891011121314151617181920212223242526272829303132
  1. world = world or nil
  2. camera = camera or nil
  3. function init()
  4. -- Set the title of the main window
  5. Window.set_title("00-hello-world")
  6. -- Create world and camera
  7. world = Device.create_world()
  8. local camera_unit = World.spawn_unit(world, "camera")
  9. camera = World.camera(world, camera_unit)
  10. end
  11. function update(dt)
  12. -- Advance the simulation
  13. World.update(world, dt)
  14. -- Stop the engine when the 'ESC' key is released
  15. if Keyboard.released(Keyboard.button_id("escape")) then
  16. Device.quit()
  17. end
  18. end
  19. function render(dt)
  20. -- Render the world
  21. Device.render_world(world, camera)
  22. end
  23. function shutdown()
  24. -- Cleanup
  25. Device.destroy_world(world)
  26. end