main.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. require "imgui"
  2. local ECS = require("ecs.ECS")
  3. local Debug = require("debug_overlay")
  4. local inspect = require 'inspect'
  5. debug_overlay = Debug:new()
  6. local ecs = ECS:new()
  7. local a = {b = 42}
  8. _G.debug_overlay = debug_overlay
  9. _G.ecs = ecs
  10. --
  11. -- LOVE callbacks
  12. --
  13. function love.load(arg)
  14. for i=0,100-1 do
  15. ecs.entities[i] = false
  16. end
  17. ecs.entities[0] = true
  18. ecs.components.test_t[0]._alive = true
  19. end
  20. function love.update(dt)
  21. imgui.NewFrame()
  22. end
  23. function love.draw()
  24. debug_overlay:render()
  25. imgui.Render();
  26. end
  27. function love.quit()
  28. imgui.ShutDown();
  29. end
  30. --
  31. -- User inputs
  32. --
  33. function love.textinput(t)
  34. imgui.TextInput(t)
  35. if not imgui.GetWantCaptureKeyboard() then
  36. -- Pass event to the game
  37. end
  38. end
  39. function love.resize(width, height)
  40. pixel = shine.pixelate()
  41. crt = shine.crt()
  42. glow = shine.glowsimple()
  43. blur = shine.boxblur()
  44. scan = shine.scanlines()
  45. pe = scan:chain(glow):chain(crt)
  46. end
  47. function love.keypressed(key)
  48. imgui.KeyPressed(key)
  49. debug_overlay:keypressed(key)
  50. if not imgui.GetWantCaptureKeyboard() then
  51. -- Pass event to the game
  52. end
  53. end
  54. function love.keyreleased(key)
  55. imgui.KeyReleased(key)
  56. if not imgui.GetWantCaptureKeyboard() then
  57. -- Pass event to the game
  58. end
  59. a = nil
  60. end
  61. function love.mousemoved(x, y)
  62. imgui.MouseMoved(x, y)
  63. if not imgui.GetWantCaptureMouse() then
  64. -- Pass event to the game
  65. end
  66. end
  67. function love.mousepressed(x, y, button)
  68. imgui.MousePressed(button)
  69. if not imgui.GetWantCaptureMouse() then
  70. -- Pass event to the game
  71. end
  72. end
  73. function love.mousereleased(x, y, button)
  74. imgui.MouseReleased(button)
  75. if not imgui.GetWantCaptureMouse() then
  76. -- Pass event to the game
  77. end
  78. end
  79. function love.wheelmoved(x, y)
  80. imgui.WheelMoved(y)
  81. if not imgui.GetWantCaptureMouse() then
  82. -- Pass event to the game
  83. end
  84. end