Browse Source

fix tower hexes deserialize thing

master
Nicholas Hayashi 4 years ago
parent
commit
d7a622df39
  1. 11
      main.lua
  2. 5
      src/game.lua
  3. 2
      src/mob.lua
  4. 2
      src/tower.lua

11
main.lua

@ -44,7 +44,7 @@ require "src/tower"
function main_action(self)
self"hex_backdrop""rotate".angle = math.wrapf(self"hex_backdrop""rotate".angle - 0.002 * am.delta_time, math.pi*2)
self"hex_backdrop""rotate".angle = math.wrapf(self"hex_backdrop""rotate".angle - 0.005 * am.delta_time, math.pi*2)
end
function make_main_scene_toolbelt()
@ -54,23 +54,19 @@ function make_main_scene_toolbelt()
false,
false,
{
label = "new game",
texture = TEXTURES.NEW_GAME_HEX,
action = function() end
action = function() game_init() end
},
{
label = "load game",
texture = TEXTURES.LOAD_GAME_HEX,
action = function() game_init(am.load_state("save", "json")) end
},
false,
{
label = "settings",
texture = TEXTURES.SETTINGS_HEX,
action = function() end
},
{
label = "about",
texture = TEXTURES.ABOUT_HEX,
action = function() end
},
@ -78,7 +74,6 @@ function make_main_scene_toolbelt()
false,
false,
{
label = "map editor",
texture = TEXTURES.MAP_EDITOR_HEX,
action = function() log("map editor not implemented") end
},
@ -167,8 +162,6 @@ function main_scene()
return group
end
win.scene = am.group()
win.scene = main_scene()
--game_init()
noglobals()

5
src/game.lua

@ -146,6 +146,11 @@ local function game_deserialize(json_string)
if t then
new_state.towers[i] = tower_deserialize(t)
for _,h in pairs(new_state.towers[i].hexes) do
local tile = hex_map_get(new_state.map, h.x, h.y)
tile.elevation = tile.elevation + new_state.towers[i].height
end
-- @STATEFUL, shouldn't be done here
new_state.world:append(new_state.towers[i].node)
end

2
src/mob.lua

@ -100,7 +100,7 @@ function make_mob_node(mob_type, mob)
if mob_type == MOB_TYPE.BEEPER then
return am.group{
am.rotate(state.time)
am.rotate(am.current_time()) -- state.time is not garunteed to be set when deserializing
^ pack_texture_into_sprite(TEXTURES.MOB_BEEPER, MOB_SIZE, MOB_SIZE),
am.translate(0, -10)
^ healthbar

2
src/tower.lua

@ -230,8 +230,8 @@ end
function tower_deserialize(json_string)
local tower = entity_basic_json_parse(json_string)
tower.hexes = {}
for i,h in pairs(tower.hexes) do
log(h)
tower.hexes[i] = vec2(tower.hexes[i][1], tower.hexes[i][2])
end

Loading…
Cancel
Save