Forked from
tome / Tales of MajEyal
15100 commits behind the upstream repository.
-
dg authored
git-svn-id: http://svn.net-core.org/repos/t-engine4@4 51575b47-30f0-44d4-a5cc-537603b46e54
dg authoredgit-svn-id: http://svn.net-core.org/repos/t-engine4@4 51575b47-30f0-44d4-a5cc-537603b46e54
Actor.lua 509 B
require "engine.class"
local Entity = require "engine.Entity"
local Map = require "engine.Map"
module(..., package.seeall, class.inherit(Entity))
function _M:init(t)
t = t or {}
self.name = t.name
Entity.init(self, t)
end
function _M:move(map, x, y)
if self.x and self.y then
map:remove(self.x, self.y, Map.ACTOR)
end
if x < 0 then x = 0 end
if x >= map.w then x = map.w - 1 end
if y < 0 then y = 0 end
if y >= map.h then y = map.h - 1 end
self.x, self.y = x, y
map(x, y, Map.ACTOR, self)
end