diff options
Diffstat (limited to 'common/chunk.lua')
-rw-r--r-- | common/chunk.lua | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/common/chunk.lua b/common/chunk.lua index 38cdaf0..432e37b 100644 --- a/common/chunk.lua +++ b/common/chunk.lua @@ -22,6 +22,11 @@ function Chunk.make() return setmetatable({tiles=tiles},Chunk) end +function Chunk.tile_at_offset(self,hoffs) + if not(0<=hoffs.q and 0<=hoffs.r and hoffs.q<CHUNK_SIZE and hoffs.r<CHUNK_SIZE) then return nil end + local idx = CHUNK_SIZE*hoffs.q + hoffs.r + return self.tiles[idx] +end return { Chunk=Chunk, |