diff options
author | ubq323 <ubq323@ubq323.website> | 2023-02-03 01:32:09 +0000 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2023-02-03 01:32:09 +0000 |
commit | ec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 (patch) | |
tree | 1893ad4fe5dc651370411f2bc84060cd7c0465cb /common | |
parent | 04664ee48de5fc8b06a584e20a4b75c41dafa558 (diff) |
drawing changes, world generation, perlin noise
Diffstat (limited to 'common')
-rw-r--r-- | common/chunk.lua | 11 | ||||
-rw-r--r-- | common/coords.lua | 2 |
2 files changed, 2 insertions, 11 deletions
diff --git a/common/chunk.lua b/common/chunk.lua index a9a8bc5..8e2ec40 100644 --- a/common/chunk.lua +++ b/common/chunk.lua @@ -20,17 +20,6 @@ Chunk.__index = Chunk function Chunk.make(tiles) return setmetatable({tiles=tiles},Chunk) end -function Chunk.gen() - -- todo actual worldgen - local tiles = {} - for i=0,CHUNK_SIZE-1 do - for j=0,CHUNK_SIZE-1 do - tiles[index(i,j)] = (math.random()<0.5) - end - end - - return Chunk.make(tiles) -end function Chunk.at(self,hoffs) if not index_ok(hoffs.q,hoffs.r) then return nil end return self.tiles[index(hoffs.q,hoffs.r)] diff --git a/common/coords.lua b/common/coords.lua index 1bb9154..2399e43 100644 --- a/common/coords.lua +++ b/common/coords.lua @@ -76,6 +76,8 @@ function Pos.__div(a,b) end function Pos.lensq(self) return self.x^2 + self.y^2 end function Pos.len(self) return math.sqrt(self:lensq()) end +function Pos.norm(self) return self/self:len() end +function Pos.dot(self,other) return self.x*other.x + self.y*other.y end function Pos.to_hex(self) local q = self.x*(SR3/3) - self.y*(1/3) local r = (2/3)*self.y |