diff --git a/examples/gameplay/plateform/actors/init.lua b/examples/gameplay/plateform/actors/init.lua index c378039..8a009b1 100644 --- a/examples/gameplay/plateform/actors/init.lua +++ b/examples/gameplay/plateform/actors/init.lua @@ -3,8 +3,12 @@ local Obj = {} -- On charge toutes les différentes types d'acteurs local cwd = (...):gsub('%.init$', '') .. "." +Obj.Player = require(cwd .. "player") + Obj.index = {} +Obj.index["player"] = require(cwd .. "player") Obj.collisions = {} +Obj.collisions["wall"] = require(cwd .. "wall") return Obj diff --git a/examples/gameplay/plateform/actors/player.lua b/examples/gameplay/plateform/actors/player.lua new file mode 100644 index 0000000..be46fb3 --- /dev/null +++ b/examples/gameplay/plateform/actors/player.lua @@ -0,0 +1,28 @@ +local Base = require "gamecore.modules.world.actors.actor2D" +local Player = Base:extend() + +function Player:new(world, x, y, id) + Player.super.new(self, world, "player", x, y, 16, 24, true) + self.playerid = id +end + +function Player:update(dt) + self.xfrc = 480*3 + + if self.keys["up"].isDown then + --self.ysp = -120 + end + if self.keys["down"].isDown then + --self.ysp = 120 + end + if self.keys["left"].isDown then + self.xsp = -120 + end + if self.keys["right"].isDown then + self.xsp = 120 + end + + Player.super.update(self, dt) +end + +return Player diff --git a/examples/gameplay/plateform/actors/wall.lua b/examples/gameplay/plateform/actors/wall.lua new file mode 100644 index 0000000..12c109d --- /dev/null +++ b/examples/gameplay/plateform/actors/wall.lua @@ -0,0 +1,8 @@ +local Base = require "gamecore.modules.world.actors.actor2D" +local Wall = Base:extend() + +function Wall:new(world, x, y, w, h) + Parent.super.new(self, world, "wall", x, y, w, h, true) +end + +return Wall