Ability to mark objects as temporary for cutscenes and have them purged afterwards.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 4dac804965
commit 83d4c55848
  1. 23
      SeasonsOfLoneliness.cpp
  2. BIN
      Seasons_of_Loneliness

@ -122,6 +122,8 @@ class Object{
vi2d spos;
vi2d size;
bool hascut=false;
bool tempObj;
Object(){};
Object(Decal*spr) {
this->spr=spr;
}
@ -516,7 +518,6 @@ public:
BASE_OBJECTS["METEORSHOWER_NODE"]=new ObjectLoadInfo(POWER_METEOR_SHOWER_DECAL,&POWER_METEOR_SHOWER_ANIMATION);
BASE_OBJECTS["METEORSTORM_NODE"]=new ObjectLoadInfo(POWER_METEOR_STORM_DECAL,&POWER_METEOR_STORM_ANIMATION);
BASE_OBJECTS["SNOWSTORM_NODE"]=new ObjectLoadInfo(POWER_SNOWSTORM_DECAL,&POWER_SNOWSTORM_ANIMATION);
BASE_OBJECTS["PLAYER_BACK"]=new ObjectLoadInfo(PLAYER_DECAL);
for (int i=0;i<MAX_PIXELS;i++) {
@ -1071,6 +1072,7 @@ public:
case cutscene::CUTSCENE_4:{
if (!messageBoxVisible) {
if (!CUTSCENE_FLAGS[0]) {
CreateObject(GetMapFileCoords(8,17),PLAYER_DECAL,{64,0},{32,32});
CUTSCENE_FLAGS[0]=true;
DisplayMessageBox(0);
} else
@ -1326,7 +1328,7 @@ public:
DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2+(obj->anim->flipped?32:0),(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->anim->spr,{obj->anim->getCurrentFrame().x,obj->anim->getCurrentFrame().y},{obj->anim->width,obj->anim->height},{obj->anim->flipped?-1:1,1});
} else
if (obj->hascut) {
DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr,obj->spos,{obj->anim->width,obj->anim->height},{obj->anim->flipped?-1:1,1});
DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr,obj->spos,obj->size);
} else {
DrawDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr);
}
@ -1796,27 +1798,38 @@ public:
PLAYER_COORDS[1]=teleLoc.y+0.5;
}
Object*createObject(vf2d pos,Decal*spr) {
Object*CreateObject(vf2d pos,Decal*spr,bool temporary=false) {
Object*newobj;
OBJECTS.push_back(newobj=new Object(spr));
newobj->x=pos.x;
newobj->y=pos.y;
newobj->tempObj=temporary;
return newobj;
}
Object*createObject(vf2d pos,Decal*spr,Animation*anim) {
Object*CreateObject(vf2d pos,Decal*spr,Animation*anim,bool temporary=false) {
Object*newobj;
OBJECTS.push_back(newobj=new Object(spr,anim));
newobj->x=pos.x;
newobj->y=pos.y;
newobj->tempObj=temporary;
return newobj;
}
Object*createObject(vf2d pos,Decal*spr,vi2d spos,vi2d size) {
Object*CreateObject(vf2d pos,Decal*spr,vi2d spos,vi2d size,bool temporary=false) {
Object*newobj;
OBJECTS.push_back(newobj=new Object(spr,spos,size));
newobj->x=pos.x;
newobj->y=pos.y;
newobj->tempObj=temporary;
return newobj;
}
void ClearAllTemporaryObjects() {
for (int i=0;i<OBJECTS.size();i++) {
if (OBJECTS[i]->tempObj) {
delete OBJECTS[i];
OBJECTS.erase(OBJECTS.begin()+i--);
}
}
}
};

Binary file not shown.
Loading…
Cancel
Save