git repos / saland

commit 33cd6471

sago007 · 2020-07-15 14:34
33cd64714654fa4b1f7749de0b6ddebca3c3ebf6 patch · browse files
parent 8328a07b2d1c5e9f2b4e2b0733ed792f4e05d420

Started on making regions more adjustable

Changed files

M src/saland/GameRegion.cpp before
M src/saland/GameRegion.hpp before
diff --git a/src/saland/GameRegion.cpp b/src/saland/GameRegion.cpp index 92c0d1d..efb3ac4 100644 --- a/src/saland/GameRegion.cpp +++ b/src/saland/GameRegion.cpp
@@ -115,6 +115,13 @@ void GameRegion::SpawnItem(const ItemDef& def, float destX, float destY) {
}
}
+std::string GameRegion::GetRegionType(int region_x, int region_y) const {
+ if (region_x == -1 && region_y == 0) {
+ return "forrest";
+ }
+ return "default";
+}
+
void GameRegion::Init(int x, int y, const std::string& worldName, bool forceResetWorld) {
region_x = x;
region_y = y;
@@ -122,7 +129,7 @@ void GameRegion::Init(int x, int y, const std::string& worldName, bool forceRese
std::string loadMap = mapFileName;
if (!sago::FileExists(loadMap.c_str()) || forceResetWorld) {
loadMap = "maps/sample1.tmx";
- if (region_x == -1 && region_y == 0) {
+ if (GetRegionType(region_x, region_y) == "forrest") {
loadMap = "maps/template_forrest.tmx";
}
if (region_x == 0 && region_y == -2) {
@@ -168,7 +175,7 @@ void GameRegion::Init(int x, int y, const std::string& worldName, bool forceRese
//Forrest region
- if (region_x == -1 && region_y == 0) {
+ if (GetRegionType(region_x, region_y) == "forrest") {
std::cout << "Forrest region\n";
for (int i=0; i<10; ++i) {
diff --git a/src/saland/GameRegion.hpp b/src/saland/GameRegion.hpp index 1099c40..5b793ae 100644 --- a/src/saland/GameRegion.hpp +++ b/src/saland/GameRegion.hpp
@@ -57,6 +57,7 @@ public:
}
void SpawnMonster(const MonsterDef& def, float destX, float destY) ;
void SpawnItem(const ItemDef& def, float destX, float destY) ;
+ std::string GetRegionType(int x, int y) const;
private:
int region_x = 0;
int region_y = 0;