summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/drawing.lua8
-rw-r--r--client/main.lua13
-rw-r--r--client/movement.lua2
-rw-r--r--server/chunk.lua4
-rw-r--r--server/server.lua4
-rw-r--r--server/worldgen.lua2
-rw-r--r--tiles.txt8
7 files changed, 20 insertions, 21 deletions
diff --git a/client/drawing.lua b/client/drawing.lua
index 31c5893..e3dc751 100644
--- a/client/drawing.lua
+++ b/client/drawing.lua
@@ -38,6 +38,8 @@ local colors = {
c(64,64,255), -- blue
c(192,0,192), -- purple
c(128,128,128), -- grey
+
+ c(0xe7,0x9e,0), -- ubqorange
}
-- precompute sins and cosines
local _coss,_sins = {},{}
@@ -59,7 +61,7 @@ local function draw_hex(cpos,color,zoom)
_corners[2*i ] = y
end
-- love.graphics.setColor(love.math.colorFromBytes(0xe7,0x9e,0))
- love.graphics.setColor(color or {0.91,0.62,0})
+ love.graphics.setColor(color)
love.graphics.polygon("fill",_corners)
if zoom > zthr0 then
love.graphics.setLineWidth(0.1)
@@ -85,10 +87,8 @@ local function draw_map(camera,map)
_h:init(q,r)
_h:to_pos(_p)
local t = map:at(_h)
- if type(t) == "number" then
+ if t ~= nil and t ~= 0 then
draw_hex(_p,colors[t],camera.zoom)
- elseif t then
- draw_hex(_p,nil,camera.zoom)
end
end
end
diff --git a/client/main.lua b/client/main.lua
index 4941814..244925e 100644
--- a/client/main.lua
+++ b/client/main.lua
@@ -95,13 +95,12 @@ function love.update(dt)
end
local mh = camera:screen_to_world(Pos:make(love.mouse.getPosition())):to_hex():round()
- if false== map:at(mh) and love.mouse.isDown(1) then
- map:set_at(mh,true)
- send_settile(mh,true)
- elseif map:at(mh) and love.mouse.isDown(2) then
- map:set_at(mh,false)
- -- print(mh,false)
- send_settile(mh,false)
+ if map:at(mh) == 0 and love.mouse.isDown(1) then
+ map:set_at(mh,9)
+ send_settile(mh,9)
+ elseif map:at(mh) ~= 0 and love.mouse.isDown(2) then
+ map:set_at(mh,0)
+ send_settile(mh,0)
end
if local_player then
diff --git a/client/movement.lua b/client/movement.lua
index 78af5f0..3c9f104 100644
--- a/client/movement.lua
+++ b/client/movement.lua
@@ -71,7 +71,7 @@ local function collide_with_terrain(old_pos, try_pos, map, tries_remaining)
local try_h = try_pos:to_hex():round()
for near_h in try_h:iter_neighbours(1) do
local tile = map:at(near_h)
- if tile then
+ if tile ~= 0 then
local d,gx,gy = hex_sdgf(try_pos, near_h)
if d < PLAYER_SIZE then
local push_dist = PLAYER_SIZE - d
diff --git a/server/chunk.lua b/server/chunk.lua
index 1e2e135..8e71327 100644
--- a/server/chunk.lua
+++ b/server/chunk.lua
@@ -15,6 +15,10 @@ function ChunkS.load_from_disk(cls,cp)
if not f then return nil end
local j = json.decode(f:read("a"))
self = cls:from_packet_data(j)
+ for i,t in ipairs(self.tiles) do
+ if t == false then self.tiles[i] = 0
+ elseif t == true then self.tiles[i] = 9 end
+ end
f:close()
return self
end
diff --git a/server/server.lua b/server/server.lua
index 88f4efe..85112c9 100644
--- a/server/server.lua
+++ b/server/server.lua
@@ -174,11 +174,11 @@ end
local function tick(ntick)
if ntick % 30 == 0 then
- print("saving things")
+ -- print("saving things")
for cp,ch in map:iter_chunks() do
map:save_chunk(cp)
if not player_near_chunk(cp) then
- print("unloading chunk",cp)
+ -- print("unloading chunk",cp)
map:remove_chunk(cp)
end
end
diff --git a/server/worldgen.lua b/server/worldgen.lua
index e4e1a4c..3f318d1 100644
--- a/server/worldgen.lua
+++ b/server/worldgen.lua
@@ -28,7 +28,7 @@ local function gen_chunk(chpos)
local ix = chunk.index(q,r)
local nv = surface_ng:at(p.x,p.y)
if nv <= 0 then
- tiles[ix] = false
+ tiles[ix] = 0
else
local nv2 = color_ng:at(p.x,p.y)
nv2 = math.max(-0.9999999,math.min(0.9999999,nv2*2.5))
diff --git a/tiles.txt b/tiles.txt
index 22ce851..7902ed4 100644
--- a/tiles.txt
+++ b/tiles.txt
@@ -1,8 +1,4 @@
-this is kind of inconsistent, it shall change soon
-
-false: nothing
+number 0: empty
number 1-8: red orange yellow green teal blue purple grey
-true: other orange. the one you can place yourself.
-
+9: other orange. the one you can place yourself.
-suggestion: use 0 for nothing. (probably don't use nil, because that's used for unloaded chunks. perhaps use false. idk)