Maybe redo map loading

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 645bcfbb2d
commit d700d8b83c
  1. 24
      SeasonsOfLoneliness.cpp
  2. BIN
      Seasons_of_Loneliness

@ -451,7 +451,7 @@ public:
std::string MAP_NAME = "";
std::string CUTSCENE_CONSOLE_TEXT = "";
bool GAME_FLAGS[128]={};
int**MAP=NULL;
int**MAP=(int**)malloc(sizeof(int**)*0);
int MAP_WIDTH=-1;
int MAP_HEIGHT=-1;
Decal*TILES;
@ -961,14 +961,14 @@ public:
ENCOUNTER_SANDWORM_1.playerY=3.5;
ENCOUNTER_SANDWORM_1.map=MAP_3;
//ENCOUNTERS.push_back(ENCOUNTER_X_X); //Activate at beginning of Chapter 2.
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Megamoth",3.5,3.25,745,745,MOVESET_MEGAMOTH,{2,2}));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",2,3,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",6,3,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",4,6.5,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Megamoth",3.5,1.75,745,745,MOVESET_MEGAMOTH,{2,2}));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",2,1,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",6,1,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.entities.push_back(new Entity(MOTH_DECAL,"Moth",4,4,120,120,MOVESET_MOTH));
ENCOUNTER_MEGAMOTH.x=195-4;
ENCOUNTER_MEGAMOTH.y=56-3.5;
ENCOUNTER_MEGAMOTH.playerX=4;
ENCOUNTER_MEGAMOTH.playerY=3.5;
ENCOUNTER_MEGAMOTH.playerY=0.5;
ENCOUNTER_MEGAMOTH.map=MAP_4;
ENCOUNTERS.push_back(ENCOUNTER_MEGAMOTH);
@ -2540,7 +2540,7 @@ public:
StartCutscene(cutscene::CHECK_COORDS_2);
CUTSCENE_OBJS[0]=CreateObject({PLAYER_COORDS[0],PLAYER_COORDS[1]},PLAYER_DECAL,playerAnim,true);
}
if(WALK_STEPS++>60&&!IN_BATTLE_ENCOUNTER) {
if(WALK_STEPS++>60&&!IN_BATTLE_ENCOUNTER&&playerCanMove()) {
PLAYER_HP=std::clamp(PLAYER_HP+1,0,PLAYER_MAXHP);
updatePlayerState();
WALK_STEPS=0;
@ -2893,14 +2893,12 @@ public:
std::ifstream f("assets/maps/"+map->filename);
std::string data;
CURRENT_MAP=map;
MAP_WIDTH=MAP_HEIGHT=-1;
if (MAP!=NULL) {
if (MAP!=nullptr) {
for (int y=0;y<MAP_HEIGHT;y++) {
free(MAP[y]);
}
free(MAP);
MAP=NULL;
}
MAP_WIDTH=MAP_HEIGHT=-1;
for (int i=0;i<OBJECTS.size();i++) {
delete OBJECTS[i];
}
@ -2919,9 +2917,7 @@ public:
stream>>MAP_HEIGHT;
} else
if (y<MAP_HEIGHT) {
if (MAP==NULL) {
MAP=(int**)malloc(sizeof(int**)*MAP_HEIGHT);
}
MAP=(int**)realloc(MAP,sizeof(int**)*MAP_HEIGHT);
MAP[y]=(int*)malloc(sizeof(int*)*MAP_WIDTH);
for (int i=0;i<data.length();i++) {
MAP[y][i]=data[i]-'0';

Binary file not shown.
Loading…
Cancel
Save