Fix issues with map height not being synced.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent a0f5e2efd6
commit 6c6266af56
  1. BIN
      C++ProjectTemplate
  2. 34
      main.cpp

Binary file not shown.

@ -107,8 +107,8 @@ public:
int frameCount=0; int frameCount=0;
float elapsedTime=0; float elapsedTime=0;
const float TARGET_RATE = 1/60.0; const float TARGET_RATE = 1/60.0;
int MAP_WIDTH; int MAP_WIDTH=-1;
int MAP_HEIGHT; int MAP_HEIGHT=-1;
Map*CURRENT_MAP; Map*CURRENT_MAP;
Map*MAP_ONETT; Map*MAP_ONETT;
vd2d cameraPos = {0,0}; vd2d cameraPos = {0,0};
@ -512,26 +512,26 @@ public:
} }
MAP[i].clear(); MAP[i].clear();
} }
for (int i=0;i<MAP2.size();i++) { for (int i=0;i<MAP.size();i++) {
for (int j=0;j<MAP2[i].size();j++) { for (int j=0;j<MAP[i].size();j++) {
delete MAP2[i][j]; delete MAP2[i][j];
} }
MAP2[i].clear(); MAP2[i].clear();
} }
for (int i=0;i<MAP3.size();i++) { for (int i=0;i<MAP.size();i++) {
for (int j=0;j<MAP3[i].size();j++) { for (int j=0;j<MAP[i].size();j++) {
delete MAP3[i][j]; delete MAP3[i][j];
} }
MAP3[i].clear(); MAP3[i].clear();
} }
for (int i=0;i<MAP4.size();i++) { for (int i=0;i<MAP.size();i++) {
for (int j=0;j<MAP4[i].size();j++) { for (int j=0;j<MAP[i].size();j++) {
delete MAP4[i][j]; delete MAP4[i][j];
} }
MAP4[i].clear(); MAP4[i].clear();
} }
for (int i=0;i<MAP5.size();i++) { for (int i=0;i<MAP.size();i++) {
for (int j=0;j<MAP5[i].size();j++) { for (int j=0;j<MAP[i].size();j++) {
delete MAP5[i][j]; delete MAP5[i][j];
} }
MAP5[i].clear(); MAP5[i].clear();
@ -539,12 +539,16 @@ public:
MAP_WIDTH=-1; MAP_WIDTH=-1;
MAP_HEIGHT=-1; MAP_HEIGHT=-1;
MAP.clear(); MAP.clear();
for (int i=0;i<OBJECTS.size();i++) {
delete OBJECTS[i];
}
OBJECTS.clear();
PLAYER_OBJ=nullptr;
std::string data; std::string data;
while (f.good()) { while (f.good()) {
f>>data; f>>data;
if (MAP_WIDTH==-1) { if (MAP_WIDTH==-1) {
MAP_WIDTH=data.length()/2; MAP_WIDTH=data.length()/2;
printf("Map Width: %d\n",MAP_WIDTH);
} }
if (data.find("OBJECT")!=std::string::npos) { if (data.find("OBJECT")!=std::string::npos) {
int marker=data.find_first_of(';'); int marker=data.find_first_of(';');
@ -636,6 +640,8 @@ public:
} }
MAP5.push_back(tiles); MAP5.push_back(tiles);
} }
MAP_WIDTH=MAP[0].size();
MAP_HEIGHT=MAP.size();
printf("Loaded map %s.\n",map->filename.c_str()); printf("Loaded map %s.\n",map->filename.c_str());
f.close(); f.close();
f2.close(); f2.close();
@ -927,12 +933,14 @@ public:
} }
} }
printf("OBJECTS (%d):\n",OBJECTS.size()); //printf("OBJECTS (%d):\n",OBJECTS.size());
for (int i=0;i<OBJECTS.size();i++) { for (int i=0;i<OBJECTS.size();i++) {
if (i!=OBJECTS[i]->objArrElement) {
printf("%d :: Object %s - %d (%lf,%lf)\n",i,OBJECTS[i]->name.c_str(),OBJECTS[i]->objArrElement,OBJECTS[i]->pos.x,OBJECTS[i]->pos.y); printf("%d :: Object %s - %d (%lf,%lf)\n",i,OBJECTS[i]->name.c_str(),OBJECTS[i]->objArrElement,OBJECTS[i]->pos.x,OBJECTS[i]->pos.y);
}
assert(i==OBJECTS[i]->objArrElement); assert(i==OBJECTS[i]->objArrElement);
} }
printf("\n"); //printf("\n");
} }

Loading…
Cancel
Save