X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FScene.cc;h=59ece168a4167089f4f9e056122115fa2f485ae9;hp=bd9c034c5f4f610ce59b80d93b328debfb71a848;hb=23d8f7a5fbd1eca7f46f2342c20ac5e28ae0128a;hpb=fa9438c66ae0154e6d9ad196e0fb39649d359da4 diff --git a/src/Scene.cc b/src/Scene.cc index bd9c034..59ece16 100644 --- a/src/Scene.cc +++ b/src/Scene.cc @@ -38,9 +38,9 @@ #include #include #include -#include #include "Scene.hh" +#include "Tilemap.hh" struct Scene::Impl : public Mf::Mippleton @@ -50,7 +50,7 @@ struct Scene::Impl : public Mf::Mippleton Mf::Scalar vertices_[12]; Mf::Scalar texCoords_[8]; - Mf::Tilemap tilemap_; + Tilemap tilemap_; bool blending_; bool fog_; @@ -68,7 +68,7 @@ struct Scene::Impl : public Mf::Mippleton }; Quad(const Mf::Vector3 vertices[4], const std::string& texture, - Mf::Tilemap::Index tileIndex) : + Tilemap::Index tileIndex) : tilemap_(texture), blending_(false), fog_(false) @@ -267,8 +267,6 @@ struct Scene::Impl : public Mf::Mippleton - Mf::Script script; - Mf::Matrix4 transform; std::string texture; @@ -287,10 +285,6 @@ struct Scene::Impl : public Mf::Mippleton explicit Impl(const std::string& name) : Mf::Mippleton(name) { - script.importStandardLibraries(); - importLogScript(script); - - importSceneBindings(script); loadFromFile(); } @@ -331,8 +325,13 @@ struct Scene::Impl : public Mf::Mippleton void loadFromFile() { + Mf::Script script; std::string filePath = Scene::getPath(getName()); + script.importStandardLibraries(); + importLogScript(script); + importSceneBindings(script); + if (script.doFile(filePath) != Mf::Script::SUCCESS) { std::string str; @@ -487,7 +486,7 @@ struct Scene::Impl : public Mf::Mippleton if (nTiles % width != 0) table.throwError("invalid number of tiles"); - std::vector< std::vector > indices; + std::vector< std::vector > indices; int i, w, h; @@ -501,7 +500,7 @@ struct Scene::Impl : public Mf::Mippleton i = 1; for (h = height - 1; h >= 0; --h) { - std::vector row; + std::vector row; for (w = 0; w < width; ++w, ++i) { @@ -509,10 +508,10 @@ struct Scene::Impl : public Mf::Mippleton script.push(long(i)); tiles.pushField(); - long index; + Tilemap::Index index; top.get(index); - row.push_back(Mf::Tilemap::Index(index)); + row.push_back(index); } indices[h] = row; @@ -527,8 +526,7 @@ struct Scene::Impl : public Mf::Mippleton { for (int w = 0; w <= width; ++w) { - vertices[h][w] = Mf::Vector4(Mf::Scalar(w), Mf::Scalar(h), 0.0, 1.0) * - transposedTransform; + vertices[h][w] = Mf::Vector4(w, h, 0.0, 1.0) * transposedTransform; } } @@ -536,7 +534,7 @@ struct Scene::Impl : public Mf::Mippleton { for (int w = 0; w < width; ++w) { - if (indices[h][w] == Mf::Tilemap::NO_TILE) continue; + if (indices[h][w] == Tilemap::NO_TILE) continue; Mf::Vector3 quadVertices[4]; @@ -607,7 +605,7 @@ struct Scene::Impl : public Mf::Mippleton quadVertices[2] = Mf::demote(vertices[1][w+1]); quadVertices[3] = Mf::demote(vertices[1][w]); - Quad* quad = new Quad(quadVertices, texture, Mf::Tilemap::Index(index)); + Quad* quad = new Quad(quadVertices, texture, Tilemap::Index(index)); quad->setBlending(blending); quad->setFog(fog);