mirror of
https://github.com/Reuh/ubiquitousse.git
synced 2025-10-27 17:19:31 +00:00
Made modules indepent
This commit is contained in:
parent
b55c6b0dfd
commit
b2d22c75d1
6 changed files with 24 additions and 12 deletions
|
|
@ -165,6 +165,11 @@ function love.resize(width, height)
|
|||
uqt.draw.height = height
|
||||
end
|
||||
end
|
||||
elseif uqt.input then -- fields required by uqt.input
|
||||
uqt.draw = {
|
||||
width = love.graphics.getWidth(),
|
||||
height = love.graphics.getHeight()
|
||||
}
|
||||
end
|
||||
|
||||
-- uqt.audio
|
||||
|
|
|
|||
3
draw.lua
3
draw.lua
|
|
@ -1,5 +1,4 @@
|
|||
-- ubiquitousse.draw
|
||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||
|
||||
--- The drawing functions: everything that affect the display/window.
|
||||
-- The coordinate system used is:
|
||||
|
|
@ -144,10 +143,12 @@ draw = {
|
|||
scissor = function(x, y, width, height) end,
|
||||
|
||||
--- The drawing area width, in pixels.
|
||||
-- @requiredby input
|
||||
-- @impl backend
|
||||
width = 800,
|
||||
|
||||
--- The drawing area height, in pixels.
|
||||
-- @requiredby input
|
||||
-- @impl backend
|
||||
height = 600,
|
||||
|
||||
|
|
|
|||
15
event.lua
15
event.lua
|
|
@ -1,7 +1,8 @@
|
|||
-- ubiquitousse.event
|
||||
local input = require((...):match("^(.-ubiquitousse)%.")..".input")
|
||||
local time = require((...):match("^(.-ubiquitousse)%.")..".time")
|
||||
local scene = require((...):match("^(.-ubiquitousse)%.")..".scene")
|
||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||
local input = uqt.input
|
||||
local time = uqt.time
|
||||
local scene = uqt.scene
|
||||
|
||||
--- The events: callback functions that will be called when something interesting occurs.
|
||||
-- Theses are expected to be redefined in the game.
|
||||
|
|
@ -16,15 +17,15 @@ return {
|
|||
-- @tparam number dt time since last call, in miliseconds
|
||||
-- @impl mixed
|
||||
update = function(dt)
|
||||
input.update(dt)
|
||||
time.update(dt)
|
||||
scene.update(dt)
|
||||
if input then input.update(dt) end
|
||||
if time then time.update(dt) end
|
||||
if scene then scene.update(dt) end
|
||||
end,
|
||||
|
||||
--- Called each time the game expect a new frame to be drawn.
|
||||
-- The screen is expected to be cleared since last frame.
|
||||
-- @impl backend
|
||||
draw = function()
|
||||
scene.draw()
|
||||
if scene then scene.draw() end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
4
init.lua
4
init.lua
|
|
@ -58,6 +58,10 @@
|
|||
-- * ubiquitousse: fully-working version in Ubiquitousse, may or may not be redefined in backend
|
||||
-- The implementation level is indicated using the "@impl level" annotation.
|
||||
--
|
||||
-- Some Ubiquitousse modules require parts of other modules to work. Because every module should work when all the others are
|
||||
-- disabled, the backend may need to provide defaults values for a few fields in disabled modules required by an enabled one.
|
||||
-- Thoses fields are indicated with "@requiredby module" annotations.
|
||||
--
|
||||
-- Regarding the documentation: Ubiquitousse used LDoc/LuaDoc styled-comments, but since LDoc hates me and my code, the
|
||||
-- generated result is complete garbage, so please read the documentation directly in the comments here.
|
||||
-- Stuff you're interested in starts with triple - (e.g., "--- This functions saves the world").
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
-- ubiquitousse.input
|
||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||
local draw = require((...):match("^(.-ubiquitousse)%.")..".draw")
|
||||
local draw = uqt.draw
|
||||
|
||||
--- Used to store inputs which were updated this frame
|
||||
-- { Input: true, ... }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
-- ubiquitousse.scene
|
||||
local time = require((...):match("^(.-ubiquitousse)%.")..".time")
|
||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||
local time = uqt.time
|
||||
|
||||
--- Returns the file path of the given module name.
|
||||
local function getPath(modname)
|
||||
|
|
@ -51,7 +52,7 @@ scene = {
|
|||
return {
|
||||
name = name or "unamed", -- The scene name.
|
||||
|
||||
time = time.new(), -- Scene-specific TimerRegistry.
|
||||
time = time and time.new(), -- Scene-specific TimerRegistry, if uqt.time is enabled.
|
||||
|
||||
enter = function(self, ...) end, -- Called when entering a scene.
|
||||
exit = function(self) end, -- Called when exiting a scene, and not expecting to come back (scene may be unloaded).
|
||||
|
|
@ -115,7 +116,7 @@ scene = {
|
|||
-- @impl ubiquitousse
|
||||
update = function(dt, ...)
|
||||
if scene.current then
|
||||
scene.current.time.update(dt)
|
||||
if time then scene.current.time.update(dt) end
|
||||
scene.current:update(dt, ...)
|
||||
end
|
||||
end,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue