modules/world: improve commenting and organisations

This commit is contained in:
Kazhnuz 2019-04-08 19:58:41 +02:00
parent f30bbc7509
commit f2680c37f3
2 changed files with 67 additions and 4 deletions

View file

@ -1,5 +1,32 @@
-- actor2D.lua :: the implementation of a 2D actor. It contain every element
-- needed to create your own 2D actors.
--[[
Copyright © 2019 Kazhnuz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
local Actor2D = Object:extend() local Actor2D = Object:extend()
-- INIT FUNCTIONS
-- Initialise the actor and its base functions
function Actor2D:new(world, type, x, y, w, h) function Actor2D:new(world, type, x, y, w, h)
self.type = type or "" self.type = type or ""
@ -23,26 +50,38 @@ function Actor2D:initPhysics(x, y, w, h)
self.h = h or 0 self.h = h or 0
end end
function Actor2D:initKeys()
self.keys = core.input.fakekeys
end
function Actor2D:register() function Actor2D:register()
self.world:registerActor(self) self.world:registerActor(self)
end end
-- INPUT FUNCTIONS
-- get input from the world object
function Actor2D:initKeys()
self.keys = core.input.fakekeys
end
function Actor2D:getInput(keys) function Actor2D:getInput(keys)
self.keys = keys or core.input.fakekeys self.keys = keys or core.input.fakekeys
end end
-- UPDATE FUNCTIONS
-- Theses functions are activated every steps
function Actor2D:update(dt) function Actor2D:update(dt)
-- here will be update actions -- here will be update actions
end end
-- MOVEMENT FUNCTIONS
-- Basic functions from the movement.
function Actor2D:move(newx, newy) function Actor2D:move(newx, newy)
self.world:moveActor(self, newx, newy) self.world:moveActor(self, newx, newy)
end end
-- DRAW FUNCTIONS
-- Draw the actors.
function Actor2D:draw() function Actor2D:draw()
-- here will be update actions -- here will be update actions
end end

View file

@ -1,3 +1,27 @@
-- baseworld.lua :: the base world object, that contain just a fast implementation
-- of a 2D world. It doesn't support collision and stuff.
--[[
Copyright © 2019 Kazhnuz
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
]]
local cwd = (...):gsub('%.baseworld$', '') .. "." local cwd = (...):gsub('%.baseworld$', '') .. "."
local BaseWorld = Object:extend() local BaseWorld = Object:extend()