game.lua 757 B

12345678910111213141516171819202122232425262728293031323334353637
  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("Hello world!")
  6. -- Create world and camera
  7. world = Device.create_world()
  8. local camera_unit = World.spawn_unit(world, "camera")
  9. camera = Unit.camera(camera_unit, "camera")
  10. Camera.set_orthographic_metrics(camera, 0, 0, 1280, 720)
  11. end
  12. function update(dt)
  13. -- Advance the simulation
  14. World.update(world, dt)
  15. -- Stop the engine when the 'ESC' key is released
  16. if Keyboard.button_released(Keyboard.ESCAPE) then
  17. Device.quit()
  18. end
  19. end
  20. function render(dt)
  21. -- Render the world
  22. Device.render_world(world, camera)
  23. end
  24. function shutdown()
  25. -- Cleanup
  26. Device.destroy_world(world)
  27. end
  28. function g_physics_callback(args)
  29. -- Do nothing
  30. end