diff --git a/C++ProjectTemplate b/C++ProjectTemplate index c0e0f5f..55f81e8 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/SeasonI.h b/SeasonI.h index f609d61..bbab166 100644 --- a/SeasonI.h +++ b/SeasonI.h @@ -136,6 +136,7 @@ class SeasonI:public PixelGameEngine{ float ReadFloatFromStream(std::ifstream&f); double ReadDoubleFromStream(std::ifstream&f); std::string ReadStringFromStream(std::ifstream&f); + void CenterCameraOnPlayer(); }; extern SeasonI*GAME; #endif \ No newline at end of file diff --git a/entity.h b/entity.h index 675df7e..3b047f8 100644 --- a/entity.h +++ b/entity.h @@ -267,6 +267,7 @@ class Entity{ //Will automatically swap items with current equipment so no need to call remove first. void EquipItem(int index) { + int prevPartyInvenSize=PARTY_INVENTORY.size(); Item*equip=nullptr; if (isPlayer) { equip=PARTY_INVENTORY[index]; @@ -291,6 +292,10 @@ class Entity{ RemoveEquip(CurrentEquip->stats.equip,index); } equipment[equip->stats.equip]=equip; + if (ITEM_SELECTION_CURSOR>=PARTY_INVENTORY.size()&&prevPartyInvenSize&1&&PARTY_INVENTORY.size()==prevPartyInvenSize-1) { + ITEM_SELECTION_OFFSET-=2; + } + ITEM_SELECTION_CURSOR=std::clamp(ITEM_SELECTION_CURSOR,0,(int)PARTY_INVENTORY.size()-1); } }; #endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index 20690f6..68b8785 100644 --- a/main.cpp +++ b/main.cpp @@ -478,7 +478,7 @@ void SeasonI::SetupAnimations() { } void SeasonI::SetupObjectInfo() { - CreateObjectInfo(new NPC_Obj(PLAYER,"player",{0,0},nullptr,{2,2},WHITE,16),"player.png",{32,32}); + CreateObjectInfo(new NPC_Obj(PLAYER,"player",{0,0},nullptr,{1,1},WHITE,16),"player.png",{32,32}); CreateObjectInfo(new NPC_Obj(NESS,"Ness",{0,0},nullptr,{1,1},YELLOW,14),"player.png",{32,32}); CreateObjectInfo(new NPC_Obj(PAULA,"Paula",{0,0},nullptr,{1,1},MAGENTA,13),"player.png",{32,32}); CreateObjectInfo(new NPC_Obj(JEFF,"Jeff",{0,0},nullptr,{1,1},DARK_GREEN,15),"player.png",{32,32}); @@ -1378,8 +1378,7 @@ void SeasonI::updateGame(){ } } if (moved) { - const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; - cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()+PARTY_MEMBER_OBJ[0]->originPoint/2-cameraOffset; + CenterCameraOnPlayer(); } if (moved&&BATTLE_ENCOUNTER==nullptr) { for (int i=0;iencounters.size();i++) { @@ -3929,14 +3928,12 @@ void SeasonI::HandleCutscenes() { for (int i=0;iSetPos(pos); } - const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; - cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()-cameraOffset; + CenterCameraOnPlayer(); CurrentCutscene->AdvanceAction(); }break; case ActionType::LOAD_FILE:{ LoadGameSaveData(SAVE_FILE_CURSOR); - const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; - cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()+PARTY_MEMBER_OBJ[0]->originPoint/2-cameraOffset; + CenterCameraOnPlayer(); GAME_STATE=GameState::GAME_WORLD; CurrentCutscene->AdvanceAction(); }break; @@ -5387,6 +5384,11 @@ void SeasonI::LoadGameSaveData(int saveSlot) { CHAPTER_NUMBER=ReadIntFromStream(file); } +void SeasonI::CenterCameraOnPlayer(){ + const vi2d cameraOffset={WIDTH/2,HEIGHT/2}; + cameraPos=PARTY_MEMBER_OBJ[0]->GetPos()+PARTY_MEMBER_OBJ[0]->originPoint/2-cameraOffset; +} + #ifndef TEST_SUITE int main() {