From 3e6810bc0fe7a60c9cc74a973cdb36df49fad805 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 29 Aug 2022 23:26:54 -0500 Subject: [PATCH] Flip support on cutscene sprites Co-authored-by: sigonasr2 --- SeasonsOfLoneliness.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/SeasonsOfLoneliness.cpp b/SeasonsOfLoneliness.cpp index 214ac56..9f76eb3 100644 --- a/SeasonsOfLoneliness.cpp +++ b/SeasonsOfLoneliness.cpp @@ -121,6 +121,7 @@ class Object{ Animation*anim; vi2d spos; vi2d size; + bool flipped; bool hascut=false; bool tempObj; Object(){}; @@ -286,6 +287,7 @@ public: cutscene::CUTSCENE CURRENT_CUTSCENE=cutscene::NONE; int CUTSCENE_TIMER=0; bool CUTSCENE_FLAGS[8]; + Object*CUTSCENE_OBJS[8]; bool messageBoxVisible=false; int messageBoxCursor; std::string messageBoxSpeaker; @@ -736,6 +738,7 @@ public: } for (int i=0;i<8;i++) { CUTSCENE_FLAGS[i]=false; + CUTSCENE_OBJS[i]=NULL; } CUTSCENE_TIMER=0; } @@ -1072,7 +1075,7 @@ public: case cutscene::CUTSCENE_4:{ if (!messageBoxVisible) { if (!CUTSCENE_FLAGS[0]) { - CreateObject(GetMapFileCoords(8,17),PLAYER_DECAL,{64,0},{32,32}); + CUTSCENE_OBJS[0]=CreateObject(GetMapFileCoords(8,17),PLAYER_DECAL,{64,0},{32,32},true); CUTSCENE_FLAGS[0]=true; DisplayMessageBox(0); } else @@ -1085,6 +1088,16 @@ public: } } }break; + case cutscene::PAN_OVER_TO_CROPS:{ + if (CUTSCENE_OBJS[0]->y>4) { + CUTSCENE_OBJS[0]->y-=MOVE_SPD; + } else + if (CUTSCENE_OBJS[0]->x>13) { + CUTSCENE_OBJS[0]->spos={32,0}; + CUTSCENE_OBJS[0]->flipped=true; + CUTSCENE_OBJS[0]->x-=MOVE_SPD; + } + }break; } switch (GAME_STATE) { @@ -1325,10 +1338,10 @@ public: DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2-16*(float)sin(frameCount*2/60.0)+16,(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},{(float)sin(frameCount*2/60.0),1},Pixel((float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0+M_PI)+65*125,255)); } else if (obj->hasAnim) { - 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}); + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2+(obj->anim->flipped?obj->anim->width: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->size); + DrawPartialDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2+(obj->flipped?obj->size.x:0),(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr,obj->spos,obj->size,{obj->flipped?-1:1,1}); } else { DrawDecal({(obj->x-PLAYER_COORDS[0])*32+WIDTH/2,(obj->y-PLAYER_COORDS[1])*32+HEIGHT/2},obj->spr); }