diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 2c8cb4f..1e9d6dc 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -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() +-- INIT FUNCTIONS +-- Initialise the actor and its base functions + function Actor2D:new(world, type, x, y, w, h) self.type = type or "" @@ -23,26 +50,38 @@ function Actor2D:initPhysics(x, y, w, h) self.h = h or 0 end -function Actor2D:initKeys() - self.keys = core.input.fakekeys -end - function Actor2D:register() self.world:registerActor(self) end +-- INPUT FUNCTIONS +-- get input from the world object + +function Actor2D:initKeys() + self.keys = core.input.fakekeys +end + function Actor2D:getInput(keys) self.keys = keys or core.input.fakekeys end +-- UPDATE FUNCTIONS +-- Theses functions are activated every steps + function Actor2D:update(dt) -- here will be update actions end +-- MOVEMENT FUNCTIONS +-- Basic functions from the movement. + function Actor2D:move(newx, newy) self.world:moveActor(self, newx, newy) end +-- DRAW FUNCTIONS +-- Draw the actors. + function Actor2D:draw() -- here will be update actions end diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 389b77b..c0f3936 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -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 BaseWorld = Object:extend()