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
|
uqt.draw.height = height
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif uqt.input then -- fields required by uqt.input
|
||||||
|
uqt.draw = {
|
||||||
|
width = love.graphics.getWidth(),
|
||||||
|
height = love.graphics.getHeight()
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- uqt.audio
|
-- uqt.audio
|
||||||
|
|
|
||||||
3
draw.lua
3
draw.lua
|
|
@ -1,5 +1,4 @@
|
||||||
-- ubiquitousse.draw
|
-- ubiquitousse.draw
|
||||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
|
||||||
|
|
||||||
--- The drawing functions: everything that affect the display/window.
|
--- The drawing functions: everything that affect the display/window.
|
||||||
-- The coordinate system used is:
|
-- The coordinate system used is:
|
||||||
|
|
@ -144,10 +143,12 @@ draw = {
|
||||||
scissor = function(x, y, width, height) end,
|
scissor = function(x, y, width, height) end,
|
||||||
|
|
||||||
--- The drawing area width, in pixels.
|
--- The drawing area width, in pixels.
|
||||||
|
-- @requiredby input
|
||||||
-- @impl backend
|
-- @impl backend
|
||||||
width = 800,
|
width = 800,
|
||||||
|
|
||||||
--- The drawing area height, in pixels.
|
--- The drawing area height, in pixels.
|
||||||
|
-- @requiredby input
|
||||||
-- @impl backend
|
-- @impl backend
|
||||||
height = 600,
|
height = 600,
|
||||||
|
|
||||||
|
|
|
||||||
15
event.lua
15
event.lua
|
|
@ -1,7 +1,8 @@
|
||||||
-- ubiquitousse.event
|
-- ubiquitousse.event
|
||||||
local input = require((...):match("^(.-ubiquitousse)%.")..".input")
|
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||||
local time = require((...):match("^(.-ubiquitousse)%.")..".time")
|
local input = uqt.input
|
||||||
local scene = require((...):match("^(.-ubiquitousse)%.")..".scene")
|
local time = uqt.time
|
||||||
|
local scene = uqt.scene
|
||||||
|
|
||||||
--- The events: callback functions that will be called when something interesting occurs.
|
--- The events: callback functions that will be called when something interesting occurs.
|
||||||
-- Theses are expected to be redefined in the game.
|
-- Theses are expected to be redefined in the game.
|
||||||
|
|
@ -16,15 +17,15 @@ return {
|
||||||
-- @tparam number dt time since last call, in miliseconds
|
-- @tparam number dt time since last call, in miliseconds
|
||||||
-- @impl mixed
|
-- @impl mixed
|
||||||
update = function(dt)
|
update = function(dt)
|
||||||
input.update(dt)
|
if input then input.update(dt) end
|
||||||
time.update(dt)
|
if time then time.update(dt) end
|
||||||
scene.update(dt)
|
if scene then scene.update(dt) end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
--- Called each time the game expect a new frame to be drawn.
|
--- Called each time the game expect a new frame to be drawn.
|
||||||
-- The screen is expected to be cleared since last frame.
|
-- The screen is expected to be cleared since last frame.
|
||||||
-- @impl backend
|
-- @impl backend
|
||||||
draw = function()
|
draw = function()
|
||||||
scene.draw()
|
if scene then scene.draw() end
|
||||||
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
|
-- * ubiquitousse: fully-working version in Ubiquitousse, may or may not be redefined in backend
|
||||||
-- The implementation level is indicated using the "@impl level" annotation.
|
-- 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
|
-- 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.
|
-- 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").
|
-- Stuff you're interested in starts with triple - (e.g., "--- This functions saves the world").
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
-- ubiquitousse.input
|
-- ubiquitousse.input
|
||||||
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
local uqt = require((...):match("^(.-ubiquitousse)%."))
|
||||||
local draw = require((...):match("^(.-ubiquitousse)%.")..".draw")
|
local draw = uqt.draw
|
||||||
|
|
||||||
--- Used to store inputs which were updated this frame
|
--- Used to store inputs which were updated this frame
|
||||||
-- { Input: true, ... }
|
-- { Input: true, ... }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
-- ubiquitousse.scene
|
-- 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.
|
--- Returns the file path of the given module name.
|
||||||
local function getPath(modname)
|
local function getPath(modname)
|
||||||
|
|
@ -51,7 +52,7 @@ scene = {
|
||||||
return {
|
return {
|
||||||
name = name or "unamed", -- The scene name.
|
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.
|
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).
|
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
|
-- @impl ubiquitousse
|
||||||
update = function(dt, ...)
|
update = function(dt, ...)
|
||||||
if scene.current then
|
if scene.current then
|
||||||
scene.current.time.update(dt)
|
if time then scene.current.time.update(dt) end
|
||||||
scene.current:update(dt, ...)
|
scene.current:update(dt, ...)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue