aboutsummaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorjacopograndi <jak.sk8@hotmail.it>2021-08-29 13:57:41 +0200
committerjacopograndi <jak.sk8@hotmail.it>2021-08-29 13:57:41 +0200
commitace5c3f3093c50ff7fa6f8b281a377e3788abbd5 (patch)
tree8a52803dc2b777822e9b1cab148bec8798bfeadf /main.cpp
parenta8bcacc95045102e67f2feabbdddf79535837554 (diff)
adding techs
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp44
1 files changed, 19 insertions, 25 deletions
diff --git a/main.cpp b/main.cpp
index e77913f..3d3534a 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,5 +1,4 @@
#include <iostream>
-#include <fstream>
#include <vector>
#include "umath/vec2.h"
@@ -12,9 +11,7 @@
#include "game/playercontrol.h"
#include "game/gst.h"
#include "game/tile.h"
-
-#include "nlohmann/json.hpp"
-using json = nlohmann::json;
+#include "game/load.h"
// state representation
/*
@@ -59,8 +56,12 @@ int main () {
float ts = 16;
Gst gst (15,15);
+ load_json(gst);
+
gst.players.emplace_back(255, 0, 0);
+ gst.players[0].res = std::vector<int> { 1000, 1000 };
gst.players.emplace_back(0, 0, 255);
+ gst.players[1].res = std::vector<int> { 1000, 1000 };
gst.ground.tiles[1] = 1;
gst.ground.tiles[8] = 1;
@@ -74,29 +75,18 @@ int main () {
gst.ground.tiles[i%(gst.ground.sizex*gst.ground.sizey)] = 1;
}
- std::ifstream file_tiles("content/tiles.json");
- json j_tiles; file_tiles >> j_tiles;
- for (auto it : j_tiles) {
- Tile tile;
- tile.name = it["name"];
- tile.move_cost = it["move_cost"];
- tile.spritebounds = vec2 { it["spritebounds"][0], it["spritebounds"][1] };
- gst.tiles.push_back(tile);
- }
+ 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);
+
- std::ifstream file_ents("content/entities.json");
- json j_ents; file_ents >> j_ents;
- for (auto it : j_ents) {
- EntityInfo ent;
- ent.name = it["name"];
- ent.move = it["move"];
- ent.spritebounds = vec2 { it["spritebounds"][0], it["spritebounds"][1] };
- gst.infos.push_back(ent);
- }
- gst.entities.emplace_back(1, 1, gst.infos[0], 0);
- gst.entities.emplace_back(2, 1, gst.infos[1], 0);
- gst.entities.emplace_back(10, 10, gst.infos[1], 1);
+ gst.entities.emplace_back(5, 1, gst.get_info("Town Center"), 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(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);
View view (vec2 { (float)graphics.resx, (float)graphics.resy });
@@ -104,6 +94,10 @@ int main () {
while(true) {
if (com.process_events()) break;
+ if (com.resx != -1) {
+ graphics.change_res(com.resx, com.resy);
+ view.res = vec2 { (float)com.resx, (float)com.resy };
+ }
vec2 mousepos { (float)com.mx, (float)com.my };
vec2 mousedelta { mousepos };
mousedelta -= mouselast;