From ec6a391cb9cf0c0feac0fe3615a59cc7cb6db2d5 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Fri, 3 Feb 2023 01:32:09 +0000 Subject: drawing changes, world generation, perlin noise --- client/drawing.lua | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'client/drawing.lua') 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 -- cgit v1.2.3