From 522a43d16e812e10ff69747ee916918b4bd29f2f Mon Sep 17 00:00:00 2001 From: jacopograndi Date: Sun, 5 Sep 2021 23:00:42 +0200 Subject: invariant added as 'inv' --- main.cpp | 69 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 33 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index d56fd93..a3c40f1 100644 --- a/main.cpp +++ b/main.cpp @@ -54,49 +54,52 @@ int main () { Player_control control; float ts = 16; - Gst gst; - gst.inv.ground { 15,15 }; - load_json(gst); + Inv inv; + inv.ground.build(15,15); - gst.players.emplace_back(255, 0, 0, 0); - gst.players[0].res = std::vector { 1500, 1500 }; - gst.players.emplace_back(0, 0, 255, 1); - gst.players[1].res = std::vector { 1500, 1500 }; - gst.players[0].level = 2; - - gst.ground.tiles[1] = 1; - gst.ground.tiles[8] = 1; - gst.ground.tiles[11] = 2; - gst.ground.tiles[12] = 2; + inv.ground.tiles[1] = 1; + inv.ground.tiles[8] = 1; + inv.ground.tiles[11] = 2; + inv.ground.tiles[12] = 2; for (int i=0; i<2000; i+=37) { - gst.ground.tiles[i%(gst.ground.sizex*gst.ground.sizey)] = 2; - gst.ground.tiles[(i+1)%(gst.ground.sizex*gst.ground.sizey)] = 2; + inv.ground.tiles[i%(inv.ground.sizex*inv.ground.sizey)] = 2; + inv.ground.tiles[(i+1)%(inv.ground.sizex*inv.ground.sizey)] = 2; } for (int i=0; i<2000; i+=71) { - gst.ground.tiles[i%(gst.ground.sizex*gst.ground.sizey)] = 1; + inv.ground.tiles[i%(inv.ground.sizex*inv.ground.sizey)] = 1; } - gst.ground.resources.emplace_back(gst.ground.at(3, 4), Resource::Type::gold); - gst.ground.resources.emplace_back(gst.ground.at(4, 4), Resource::Type::food); + inv.ground.resources.emplace_back(inv.ground.at(3, 4), Resource::Type::gold); + inv.ground.resources.emplace_back(inv.ground.at(4, 4), Resource::Type::food); + + Gst gst { &inv }; + + load_json(inv); + + gst.players.emplace_back(255, 0, 0, 0); + gst.players[0].res = std::vector { 1500, 1500 }; + gst.players.emplace_back(0, 0, 255, 1); + gst.players[1].res = std::vector { 1500, 1500 }; + gst.players[0].level = 2; - gst.entities.emplace_back(5, 1, gst.get_info("Town Center"), 0); - gst.entities.emplace_back(6, 1, gst.get_info("Barracks"), 0); - gst.entities.emplace_back(5, 0, gst.get_info("Stable"), 0); - gst.entities.emplace_back(4, 1, gst.get_info("Market"), 0); - gst.entities.emplace_back(1, 1, gst.get_info("Villager"), 0); - gst.entities.emplace_back(2, 1, gst.get_info("Light Cavalry"), 0); - gst.entities.emplace_back(4, 2, gst.get_info("Light Cavalry"), 1); - gst.entities.emplace_back(10, 10, gst.get_info("Villager"), 1); - gst.entities.emplace_back(1, 5, gst.get_info("Villager"), 1); - gst.entities.emplace_back(2, 5, gst.get_info("Militia"), 1); - gst.entities.emplace_back(0, 0, gst.get_info("Scout Cavalry"), 0); - gst.entities.emplace_back(1, 0, gst.get_info("Persian War Elephants"), 0); - gst.entities.emplace_back(0, 1, gst.get_info("Scorpions"), 1); - gst.entities.emplace_back(1, 2, gst.get_info("Archers"), 1); - gst.entities.emplace_back(4, 3, gst.get_info("Monks"), 0); + gst.entities.emplace_back(5, 1, inv.get_info("Town Center"), 0); + gst.entities.emplace_back(6, 1, inv.get_info("Barracks"), 0); + gst.entities.emplace_back(5, 0, inv.get_info("Stable"), 0); + gst.entities.emplace_back(4, 1, inv.get_info("Market"), 0); + gst.entities.emplace_back(1, 1, inv.get_info("Villager"), 0); + gst.entities.emplace_back(2, 1, inv.get_info("Light Cavalry"), 0); + gst.entities.emplace_back(4, 2, inv.get_info("Light Cavalry"), 1); + gst.entities.emplace_back(10, 10, inv.get_info("Villager"), 1); + gst.entities.emplace_back(1, 5, inv.get_info("Villager"), 1); + gst.entities.emplace_back(2, 5, inv.get_info("Militia"), 1); + gst.entities.emplace_back(0, 0, inv.get_info("Scout Cavalry"), 0); + gst.entities.emplace_back(1, 0, inv.get_info("Persian War Elephants"), 0); + gst.entities.emplace_back(0, 1, inv.get_info("Scorpions"), 1); + gst.entities.emplace_back(1, 2, inv.get_info("Archers"), 1); + gst.entities.emplace_back(4, 3, inv.get_info("Monks"), 0); View view (vec2 { (float)graphics.resx, (float)graphics.resy }); -- cgit v1.2.3-54-g00ecf