summaryrefslogtreecommitdiff
path: root/client/drawing.lua
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2023-02-03 01:32:09 +0000
committerubq323 <ubq323@ubq323.website>2023-02-03 01:32:09 +0000
commitec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 (patch)
tree1893ad4fe5dc651370411f2bc84060cd7c0465cb /client/drawing.lua
parent04664ee48de5fc8b06a584e20a4b75c41dafa558 (diff)
drawing changes, world generation, perlin noise
Diffstat (limited to 'client/drawing.lua')
-rw-r--r--client/drawing.lua34
1 files changed, 28 insertions, 6 deletions
diff --git a/client/drawing.lua b/client/drawing.lua
index 962fdb7..111b2e2 100644
--- a/client/drawing.lua
+++ b/client/drawing.lua
@@ -26,8 +26,26 @@ end
-- love.graphics.pop()
-- end
+local function c(...) return {love.math.colorFromBytes(...)} end
+-- taken from breadquest
+local colors = {
+ c(255,64,64), -- red
+ c(255,128,0), -- orange
+ c(192,192,64), -- yellow
+ c(0,192,0), -- green
+
+ c(0,192,192), -- teal
+ c(64,64,255), -- blue
+ c(192,0,192), -- purple
+ c(128,128,128), -- grey
+}
+
+
+
+local zthr0 = 2
+local zthr1 = 5
local _corners = {}
-local function draw_hex(cpos,color)
+local function draw_hex(cpos,color,zoom)
local cx,cy = cpos.x,cpos.y
for i=0,5 do
local angle = tau*(i+0.5)/6
@@ -36,12 +54,14 @@ local function draw_hex(cpos,color)
_corners[2*i+1] = x
_corners[2*i+2] = y
end
- love.graphics.setLineWidth(0.1)
-- love.graphics.setColor(love.math.colorFromBytes(0xe7,0x9e,0))
love.graphics.setColor(color or {0.91,0.62,0})
love.graphics.polygon("fill",_corners)
- love.graphics.setColor(0,0,0)
- love.graphics.polygon("line",_corners)
+ if zoom > zthr0 then
+ love.graphics.setLineWidth(0.1)
+ love.graphics.setColor(0,0,0,zoom>zthr1 and 1 or (zoom-zthr0)/(zthr1-zthr0))
+ love.graphics.polygon("line",_corners)
+ end
end
local function draw_chunk(camera,the_chunk)
@@ -56,8 +76,10 @@ local function draw_chunk(camera,the_chunk)
for q = minq,maxq do
local h = coords.Hex.make(q,r)
local t = the_chunk:at(h)
- if t then
- draw_hex(h:to_pos())
+ if type(t) == "number" then
+ draw_hex(h:to_pos(),colors[t],camera.zoom)
+ elseif t then
+ draw_hex(h:to_pos(),nil,camera.zoom)
end
end
end