examples/plateformer: add basic actors

This commit is contained in:
Kazhnuz 2019-04-29 16:13:09 +02:00
parent dacff225a2
commit a52abd0b97
3 changed files with 40 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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