]> git.localhorst.tv Git - blobs.git/blobdiff - src/app/app.cpp
lose weight through exercise
[blobs.git] / src / app / app.cpp
index 0ec22b02c16607d189cda86107140d14ccde643f..3f87c8f5cf39011e0734d936bf315e1be7ababdb 100644 (file)
@@ -176,6 +176,7 @@ Assets::Assets()
 , font_path(path + "fonts/")
 , skin_path(path + "skins/")
 , tile_path(path + "tiles/")
+, random(0x6283B64CEFE47925)
 , fonts{
        graphics::Font(font_path + "DejaVuSans.ttf", 32),
        graphics::Font(font_path + "DejaVuSans.ttf", 24),
@@ -188,7 +189,7 @@ Assets::Assets()
        }
 
        {
-               std::ifstream tile_file(data_path + "tiles");
+               std::ifstream tile_file(data_path + "tile_types");
                io::TokenStreamReader tile_reader(tile_file);
                ReadTileTypes(tile_reader);
        }
@@ -211,18 +212,17 @@ Assets::Assets()
        LoadTileTexture("tundra",   textures.tiles, 11);
        LoadTileTexture("water",    textures.tiles, 12);
        LoadTileTexture("wheat",    textures.tiles, 13);
+       textures.tiles.FilterTrilinear();
 
        textures.skins.Bind();
        textures.skins.Reserve(256, 256, 9, format);
-       LoadSkinTexture("1", textures.skins, 0);
-       LoadSkinTexture("2", textures.skins, 1);
-       LoadSkinTexture("3", textures.skins, 2);
-       LoadSkinTexture("4", textures.skins, 3);
-       LoadSkinTexture("5", textures.skins, 4);
-       LoadSkinTexture("6", textures.skins, 5);
-       LoadSkinTexture("7", textures.skins, 6);
-       LoadSkinTexture("8", textures.skins, 7);
-       LoadSkinTexture("9", textures.skins, 8);
+       LoadSkinTexture("plain", textures.skins, 0);
+       LoadSkinTexture("stripes", textures.skins, 1);
+       LoadSkinTexture("dots", textures.skins, 2);
+       LoadSkinTexture("lines", textures.skins, 3);
+       LoadSkinTexture("spots", textures.skins, 4);
+       LoadSkinTexture("circles", textures.skins, 5);
+       textures.skins.FilterTrilinear();
 }
 
 Assets::~Assets() {
@@ -249,6 +249,11 @@ void Assets::ReadResources(io::TokenStreamReader &in) {
                        in.Skip(io::Token::EQUALS);
                        if (name == "label") {
                                in.ReadString(data.resources[id].label);
+                       } else if (name == "density") {
+                               data.resources[id].density = in.GetDouble();
+                       } else if (name == "energy") {
+                               data.resources[id].energy = in.GetDouble();
+                               data.resources[id].inverse_energy = 1.0 / data.resources[id].energy;
                        } else if (name == "state") {
                                in.ReadIdentifier(name);
                                if (name == "solid") {
@@ -262,6 +267,8 @@ void Assets::ReadResources(io::TokenStreamReader &in) {
                                } else {
                                        throw std::runtime_error("unknown resource state '" + name + "'");
                                }
+                       } else if (name == "base_color") {
+                               in.ReadVec(data.resources[id].base_color);
                        } else {
                                throw std::runtime_error("unknown resource property '" + name + "'");
                        }
@@ -279,12 +286,12 @@ void Assets::ReadTileTypes(io::TokenStreamReader &in) {
                in.Skip(io::Token::EQUALS);
 
                int id = 0;
-               if (data.tiles.Has(name)) {
-                       id = data.tiles[name].id;
+               if (data.tile_types.Has(name)) {
+                       id = data.tile_types[name].id;
                } else {
                        world::TileType type;
                        type.name = name;
-                       id = data.tiles.Add(type);
+                       id = data.tile_types.Add(type);
                }
 
                in.Skip(io::Token::ANGLE_BRACKET_OPEN);
@@ -292,9 +299,9 @@ void Assets::ReadTileTypes(io::TokenStreamReader &in) {
                        in.ReadIdentifier(name);
                        in.Skip(io::Token::EQUALS);
                        if (name == "label") {
-                               in.ReadString(data.tiles[id].label);
+                               in.ReadString(data.tile_types[id].label);
                        } else if (name == "texture") {
-                               data.tiles[id].texture = in.GetInt();
+                               data.tile_types[id].texture = in.GetInt();
                        } else if (name == "yield") {
                                in.Skip(io::Token::BRACKET_OPEN);
                                while (in.Peek().type != io::Token::BRACKET_CLOSE) {
@@ -314,7 +321,7 @@ void Assets::ReadTileTypes(io::TokenStreamReader &in) {
                                                in.Skip(io::Token::SEMICOLON);
                                        }
                                        in.Skip(io::Token::ANGLE_BRACKET_CLOSE);
-                                       data.tiles[id].resources.push_back(yield);
+                                       data.tile_types[id].resources.push_back(yield);
                                        if (in.Peek().type == io::Token::COMMA) {
                                                in.Skip(io::Token::COMMA);
                                        }