summaryrefslogtreecommitdiff
path: root/client/drawing.lua
diff options
context:
space:
mode:
Diffstat (limited to 'client/drawing.lua')
-rw-r--r--client/drawing.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/client/drawing.lua b/client/drawing.lua
new file mode 100644
index 0000000..e65e716
--- /dev/null
+++ b/client/drawing.lua
@@ -0,0 +1,40 @@
+local coords=require"common.coords"
+local Pos = coords.Pos
+local chunk = require"common.chunk"
+
+local tau=math.pi*2
+
+local corners = {}
+for i=0,5 do
+ local angle = tau*(i+0.5)/6
+ local x = math.cos(angle)
+ local y = math.sin(angle)
+ table.insert(corners,x)
+ table.insert(corners,y)
+end
+
+local function draw_hex(cpos,size)
+ love.graphics.push()
+ love.graphics.setLineWidth(0.1)
+ love.graphics.translate(cpos.x,cpos.y)
+ love.graphics.scale(size)
+ love.graphics.setColor(love.math.colorFromBytes(0xe7,0x9e,0))
+ love.graphics.polygon("fill",corners)
+ love.graphics.setColor(0,0,0)
+ love.graphics.polygon("line",corners)
+ love.graphics.pop()
+end
+
+local function draw_chunk(the_chunk)
+ for q = 0,chunk.SIZE-1 do
+ for r = 0,chunk.SIZE-1 do
+ local t = the_chunk.tiles[chunk.index(q,r)]
+ if t then
+ local p = coords.Hex.make(q,r):to_pos()
+ draw_hex(p*10,10)
+ end
+ end
+ end
+end
+
+return {draw_hex=draw_hex,draw_chunk=draw_chunk}