From 262bf97e67e951f3afee44fe2aaf4d9d464cf3c4 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 7 Apr 2019 18:33:41 +0200 Subject: [PATCH] modules/world: add basic move functions to entities --- gamecore/modules/world/actors/actor2D.lua | 4 ++++ gamecore/modules/world/baseworld.lua | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index a967c92..1a351e2 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -28,6 +28,10 @@ function Actor2D:update(dt) -- here will be update actions end +function Actor2D:move(newx, newy) + self.world:moveActor(self, newx, newy) +end + function Actor2D:draw() -- here will be update actions end diff --git a/gamecore/modules/world/baseworld.lua b/gamecore/modules/world/baseworld.lua index 6d671da..8436397 100644 --- a/gamecore/modules/world/baseworld.lua +++ b/gamecore/modules/world/baseworld.lua @@ -57,8 +57,8 @@ function BaseWorld:removeActor(actor) end function BaseWorld:moveActor(actor, x, y, filter) - self.actors[actor].x = x - self.actors[actor].y = y + actor.x = x + actor.y = y -- as the baseworld have no collision function, we return empty collision -- datas, but from the same type than bump2D will return return x, y, {}, 0