summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/drawing.lua34
-rw-r--r--client/main.lua14
2 files changed, 36 insertions, 12 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
diff --git a/client/main.lua b/client/main.lua
index 6572621..2fad49e 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -24,7 +24,7 @@ local host,peer
local chunk
-local f3mode = true
+local f3mode = false
function love.keypressed(key,scancode,isrepeat)
if scancode == "f3" then f3mode = not f3mode end
@@ -58,8 +58,8 @@ local function update_local_player(pl,dt)
end
if dx ~= 0 and dy ~= 0 then
- dx = dx / math.sqrt(2)
- dy = dy / math.sqrt(2)
+ dx = dx * 0.5
+ dy = dy * (math.sqrt(3)/2)
end
pl.pos.x = pl.pos.x + SPEED * dt * dx
@@ -91,11 +91,11 @@ function love.update(dt)
local mh = camera:screen_to_world(Pos.make(love.mouse.getPosition())):to_hex():round()
if false== chunk:at(mh) and love.mouse.isDown(1) then
chunk:set_at(mh,true)
- print(mh,true)
+ -- print(mh,true)
send_settile(mh,true)
elseif chunk:at(mh) and love.mouse.isDown(2) then
chunk:set_at(mh,false)
- print(mh,false)
+ -- print(mh,false)
send_settile(mh,false)
end
end
@@ -164,7 +164,9 @@ function love.draw()
"mh "..tostring(hm).." "..tostring(hm:round()),
"-",
"pw "..tostring(local_player.pos),
- "ph "..tostring(local_player.pos:to_hex()).." "..tostring(local_player.pos:to_hex():round())
+ "ph "..tostring(local_player.pos:to_hex()).." "..tostring(local_player.pos:to_hex():round()),
+ "-",
+ "voob "..tostring(camera.zoom),
},10,10)
end
end