| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- require "imgui"
- local ECS = require("ecs.ECS")
- local Debug = require("debug_overlay")
- local inspect = require 'inspect'
- debug_overlay = Debug:new()
- local ecs = ECS:new()
- local a = {b = 42}
- local Position = ecs:create_component("Position", [[
- int32_t x;
- int32_t y;
- ]])
- local p = ecs:get_component("Position", 42)
- _G.debug_overlay = debug_overlay
- _G.ecs = ecs
- --
- -- LOVE callbacks
- --
- function love.load(arg)
- debug_overlay.console:debug("Have fun!")
- p = Position:new()
- p.x = 2
- p.y = 5
- debug_overlay.watch:add(p, "x")
- debug_overlay.watch:add(p, "y")
- end
- function love.update(dt)
- imgui.NewFrame()
- end
- function love.draw()
- debug_overlay:render()
- imgui.Render();
- end
- function love.quit()
- imgui.ShutDown();
- end
- --
- -- User inputs
- --
- function love.textinput(t)
- imgui.TextInput(t)
- if not imgui.GetWantCaptureKeyboard() then
- -- Pass event to the game
- end
- end
- function love.resize(width, height)
- pixel = shine.pixelate()
- crt = shine.crt()
- glow = shine.glowsimple()
- blur = shine.boxblur()
- scan = shine.scanlines()
- pe = scan:chain(glow):chain(crt)
- end
- function love.keypressed(key)
- imgui.KeyPressed(key)
- debug_overlay:keypressed(key)
- if not imgui.GetWantCaptureKeyboard() then
- -- Pass event to the game
- end
- end
- function love.keyreleased(key)
- imgui.KeyReleased(key)
- if not imgui.GetWantCaptureKeyboard() then
- -- Pass event to the game
- end
- a = nil
- end
- function love.mousemoved(x, y)
- imgui.MouseMoved(x, y)
- if not imgui.GetWantCaptureMouse() then
- -- Pass event to the game
- end
- end
- function love.mousepressed(x, y, button)
- imgui.MousePressed(button)
- if not imgui.GetWantCaptureMouse() then
- -- Pass event to the game
- end
- end
- function love.mousereleased(x, y, button)
- imgui.MouseReleased(button)
- if not imgui.GetWantCaptureMouse() then
- -- Pass event to the game
- end
- end
- function love.wheelmoved(x, y)
- imgui.WheelMoved(y)
- if not imgui.GetWantCaptureMouse() then
- -- Pass event to the game
- end
- end
|