Fix missing strategy draw call for monsters. Add in death state and basic transition effects. Release Build 7662.

mac-build
sigonasr2 9 months ago
parent 8fc5b530b4
commit 9f1e6b69db
  1. 8
      Adventures in Lestoria/Adventures in Lestoria.vcxproj
  2. 6
      Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters
  3. 21
      Adventures in Lestoria/AdventuresInLestoria.cpp
  4. 7
      Adventures in Lestoria/Audio.cpp
  5. 1
      Adventures in Lestoria/Audio.h
  6. 2
      Adventures in Lestoria/GameState.cpp
  7. 1
      Adventures in Lestoria/GameState.h
  8. 6
      Adventures in Lestoria/Player.cpp
  9. 1
      Adventures in Lestoria/Player.h
  10. 1
      Adventures in Lestoria/State.h
  11. 96
      Adventures in Lestoria/State_Death.cpp
  12. 51
      Adventures in Lestoria/State_Death.h
  13. 2
      Adventures in Lestoria/Version.h
  14. 4
      Adventures in Lestoria/olcPixelGameEngine.h
  15. BIN
      x64/Release/Adventures in Lestoria.exe

@ -480,6 +480,10 @@
<ClInclude Include="SoundEffect.h" /> <ClInclude Include="SoundEffect.h" />
<ClInclude Include="SpawnEncounterLabel.h" /> <ClInclude Include="SpawnEncounterLabel.h" />
<ClInclude Include="State.h" /> <ClInclude Include="State.h" />
<ClInclude Include="State_Death.h">
<SubType>
</SubType>
</ClInclude>
<ClInclude Include="State_GameHub.h"> <ClInclude Include="State_GameHub.h">
<SubType> <SubType>
</SubType> </SubType>
@ -720,6 +724,10 @@
<SubType> <SubType>
</SubType> </SubType>
</ClCompile> </ClCompile>
<ClCompile Include="State_Death.cpp">
<SubType>
</SubType>
</ClCompile>
<ClCompile Include="State_GameHub.cpp"> <ClCompile Include="State_GameHub.cpp">
<SubType> <SubType>
</SubType> </SubType>

@ -468,6 +468,9 @@
<ClInclude Include="LoadingScreen.h"> <ClInclude Include="LoadingScreen.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="State_Death.h">
<Filter>Header Files\State</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="Player.cpp"> <ClCompile Include="Player.cpp">
@ -821,6 +824,9 @@
<ClCompile Include="packkey.cpp"> <ClCompile Include="packkey.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="State_Death.cpp">
<Filter>Source Files\Game States</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="cpp.hint" /> <None Include="cpp.hint" />

@ -1172,8 +1172,8 @@ void AiL::RenderWorld(float fElapsedTime){
for(auto it=monstersBeforeLower.begin();it!=monstersBeforeLower.end();++it){ for(auto it=monstersBeforeLower.begin();it!=monstersBeforeLower.end();++it){
Monster&m=**it; Monster&m=**it;
if(m.pos.y<tile->group->GetCollisionRange().middle().y){ if(m.pos.y<tile->group->GetCollisionRange().middle().y){
m.Draw();
m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy()); m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy());
m.Draw();
it=monstersBeforeLower.erase(it); it=monstersBeforeLower.erase(it);
if(it==monstersBeforeLower.end())break; if(it==monstersBeforeLower.end())break;
if(it!=monstersBeforeLower.begin())--it; if(it!=monstersBeforeLower.begin())--it;
@ -1225,8 +1225,8 @@ void AiL::RenderWorld(float fElapsedTime){
for(auto it=monstersAfterLower.begin();it!=monstersAfterLower.end();++it){ for(auto it=monstersAfterLower.begin();it!=monstersAfterLower.end();++it){
Monster&m=**it; Monster&m=**it;
if(m.pos.y<tile->group->GetCollisionRange().middle().y){ if(m.pos.y<tile->group->GetCollisionRange().middle().y){
m.Draw();
m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy()); m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy());
m.Draw();
it=monstersAfterLower.erase(it); it=monstersAfterLower.erase(it);
if(it==monstersAfterLower.end())break; if(it==monstersAfterLower.end())break;
if(it!=monstersAfterLower.begin())--it; if(it!=monstersAfterLower.begin())--it;
@ -1277,7 +1277,8 @@ void AiL::RenderWorld(float fElapsedTime){
} }
#pragma endregion #pragma endregion
#pragma region Remaining Rendering #pragma region Remaining Rendering
for(const Monster*const m:monstersBeforeLower){ for(Monster*m:monstersBeforeLower){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw(); m->Draw();
} }
for(const Bullet*const b:bulletsLower){ for(const Bullet*const b:bulletsLower){
@ -1297,7 +1298,8 @@ void AiL::RenderWorld(float fElapsedTime){
} }
RenderPlayer(player->GetPos(),{1,1}); RenderPlayer(player->GetPos(),{1,1});
} }
for(const Monster*const m:monstersAfterLower){ for(Monster* m:monstersAfterLower){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw(); m->Draw();
} }
for(const int dropInd:dropsAfterLower){ for(const int dropInd:dropsAfterLower){
@ -1419,8 +1421,8 @@ void AiL::RenderWorld(float fElapsedTime){
for(auto it=monstersBeforeUpper.begin();it!=monstersBeforeUpper.end();++it){ for(auto it=monstersBeforeUpper.begin();it!=monstersBeforeUpper.end();++it){
Monster&m=**it; Monster&m=**it;
if(m.pos.y<tile->group->GetCollisionRange().middle().y){ if(m.pos.y<tile->group->GetCollisionRange().middle().y){
m.Draw();
m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy()); m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy());
m.Draw();
it=monstersBeforeUpper.erase(it); it=monstersBeforeUpper.erase(it);
if(it==monstersBeforeUpper.end())break; if(it==monstersBeforeUpper.end())break;
if(it!=monstersBeforeUpper.begin())--it; if(it!=monstersBeforeUpper.begin())--it;
@ -1472,8 +1474,8 @@ void AiL::RenderWorld(float fElapsedTime){
for(auto it=monstersAfterUpper.begin();it!=monstersAfterUpper.end();++it){ for(auto it=monstersAfterUpper.begin();it!=monstersAfterUpper.end();++it){
Monster&m=**it; Monster&m=**it;
if(m.pos.y<tile->group->GetCollisionRange().middle().y){ if(m.pos.y<tile->group->GetCollisionRange().middle().y){
m.Draw();
m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy()); m.strategyDraw(this,m,MONSTER_DATA[m.GetName()].GetAIStrategy());
m.Draw();
it=monstersAfterUpper.erase(it); it=monstersAfterUpper.erase(it);
if(it==monstersAfterUpper.end())break; if(it==monstersAfterUpper.end())break;
if(it!=monstersAfterUpper.begin())--it; if(it!=monstersAfterUpper.begin())--it;
@ -1516,7 +1518,8 @@ void AiL::RenderWorld(float fElapsedTime){
} }
#pragma endregion #pragma endregion
#pragma region Remaining Upper Rendering #pragma region Remaining Upper Rendering
for(const Monster*const m:monstersBeforeUpper){ for(Monster*m:monstersBeforeUpper){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw(); m->Draw();
} }
for(const Bullet*const b:bulletsUpper){ for(const Bullet*const b:bulletsUpper){
@ -1536,7 +1539,8 @@ void AiL::RenderWorld(float fElapsedTime){
} }
RenderPlayer(player->GetPos(),{1,1}); RenderPlayer(player->GetPos(),{1,1});
} }
for(const Monster*const m:monstersAfterUpper){ for(Monster*m:monstersAfterUpper){
m->strategyDraw(this,*m,MONSTER_DATA[m->GetName()].GetAIStrategy());
m->Draw(); m->Draw();
} }
for(const int dropInd:dropsAfterUpper){ for(const int dropInd:dropsAfterUpper){
@ -2028,6 +2032,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
GetPlayer()->ResetAccumulatedXP(); GetPlayer()->ResetAccumulatedXP();
GetPlayer()->SetIframes(0.f); GetPlayer()->SetIframes(0.f);
GetPlayer()->SetInvisible(false); GetPlayer()->SetInvisible(false);
GetPlayer()->ResetVelocity();
ZONE_LIST=game->MAP_DATA[game->GetCurrentLevel()].ZoneData; ZONE_LIST=game->MAP_DATA[game->GetCurrentLevel()].ZoneData;
return true; return true;

@ -364,6 +364,13 @@ void Audio::SetBGMVolume(float vol){
channelListIndex++; channelListIndex++;
} }
} }
void Audio::SetBGMPitch(float pitch){
BGM&track=Self().bgm[Self().playParams.sound];
for(int channelListIndex=0;int trackID:track.GetChannelIDs()){
Engine().SetPitch(trackID,pitch);
channelListIndex++;
}
}
void Audio::SetSFXVolume(float vol){ void Audio::SetSFXVolume(float vol){
sfxVol=vol; sfxVol=vol;
} }

@ -70,6 +70,7 @@ public:
static void SetAudioEvent(const Event&eventName); static void SetAudioEvent(const Event&eventName);
static const bool BGMIsPlaying(); static const bool BGMIsPlaying();
static const bool BGMFullyLoaded(); //Fully loaded means when the audio buffer has finished filling up, which means sound is now playing. static const bool BGMFullyLoaded(); //Fully loaded means when the audio buffer has finished filling up, which means sound is now playing.
static void SetBGMPitch(float pitch);
static void SetBGMVolume(float vol); static void SetBGMVolume(float vol);
static void SetSFXVolume(float vol); static void SetSFXVolume(float vol);
static float&GetBGMVolume(); static float&GetBGMVolume();

@ -42,6 +42,7 @@ All rights reserved.
#include "State_LevelComplete.h" #include "State_LevelComplete.h"
#include "State_Story.h" #include "State_Story.h"
#include "State_GameHub.h" #include "State_GameHub.h"
#include "State_Death.h";
INCLUDE_game INCLUDE_game
@ -54,6 +55,7 @@ void GameState::Initialize(){
NEW_STATE(States::LEVEL_COMPLETE,State_LevelComplete); NEW_STATE(States::LEVEL_COMPLETE,State_LevelComplete);
NEW_STATE(States::STORY,State_Story); NEW_STATE(States::STORY,State_Story);
NEW_STATE(States::GAME_HUB,State_GameHub); NEW_STATE(States::GAME_HUB,State_GameHub);
NEW_STATE(States::DEATH,State_Death);
GameState::ChangeState(States::MAIN_MENU); GameState::ChangeState(States::MAIN_MENU);
} }

@ -52,6 +52,7 @@ namespace States{
LEVEL_COMPLETE, LEVEL_COMPLETE,
STORY, STORY,
KEYBIND, KEYBIND,
DEATH,
}; };
}; };

@ -717,6 +717,8 @@ bool Player::Hurt(int damage,bool onUpperLevel,float z){
} }
if(Menu::IsMenuOpen()&&mod_dmg>0)Menu::CloseAllMenus(); if(Menu::IsMenuOpen()&&mod_dmg>0)Menu::CloseAllMenus();
hp=std::max(0,hp-int(mod_dmg)); hp=std::max(0,hp-int(mod_dmg));
if(hp==0&&GameState::STATE!=GameState::states[States::DEATH])GameState::ChangeState(States::DEATH);
hurtRumbleTime="Player.Hurt Rumble Time"_F; hurtRumbleTime="Player.Hurt Rumble Time"_F;
Input::StartVibration(); Input::StartVibration();
@ -1358,4 +1360,8 @@ void Player::SetInvisible(const bool invisibleState){
const bool Player::IsInvisible()const{ const bool Player::IsInvisible()const{
return invisibility; return invisibility;
}
void Player::ResetVelocity(){
vel={};
} }

@ -247,6 +247,7 @@ public:
void SetLevel(uint8_t newLevel); void SetLevel(uint8_t newLevel);
void SetInvisible(const bool invisibleState); void SetInvisible(const bool invisibleState);
const bool IsInvisible()const; const bool IsInvisible()const;
void ResetVelocity();
private: private:
int hp="Warrior.BaseHealth"_I; int hp="Warrior.BaseHealth"_I;
int mana="Player.BaseMana"_I; int mana="Player.BaseMana"_I;

@ -56,5 +56,6 @@ namespace State{
JUMP, JUMP,
RECOVERY, RECOVERY,
FORCE_WALK, FORCE_WALK,
DEATH,
}; };
} }

@ -0,0 +1,96 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#include "State_Death.h"
#include "AdventuresInLestoria.h"
#include "DEFINES.h"
#include "Menu.h"
#include "ItemDrop.h"
#include "VisualNovel.h"
#include "State_OverworldMap.h"
#include "GameEvent.h"
#include "MenuComponent.h"
#include "Unlock.h"
INCLUDE_MONSTER_LIST
INCLUDE_game
void State_Death::OnStateChange(GameState*prevState){
if(Menu::IsMenuOpen()){
Menu::CloseAllMenus();
}
game->GetPlayer()->SetState(State::DEATH);
}
void State_Death::OnLevelLoad(){
Component<MenuComponent>(MenuType::PAUSE,"Return to Camp Button")->SetGrayedOut(
!Unlock::IsUnlocked("HUB")||game->GetCurrentMapName()=="HUB"
);
}
void State_Death::OnUserUpdate(AiL*game){
accTime+=game->GetElapsedTime();
if(gameSlowdownPct<10.f){
gameSlowdownPct+=3.f*game->GetElapsedTime();
}else{
game->SetMosaicEffect(1U);
}
game->view.SetZoom(util::lerp(1.f,2.f,(gameSlowdownPct-1)/10.f),game->view.WorldToScreen(game->GetPlayer()->GetPos()));
game->SetWorldColor({uint8_t(util::lerp(255,0,(gameSlowdownPct-1)/10.f)),uint8_t(util::lerp(255,0,(gameSlowdownPct-1)/10.f)),uint8_t(util::lerp(255,0,(gameSlowdownPct-1)/10.f)),255});
Audio::SetBGMPitch(util::lerp(1.f,0,(gameSlowdownPct-1)/10.f));
if(gameSlowdownPct<5.f){
game->SetMosaicEffect(uint8_t(util::lerp(1.f,4.f,(gameSlowdownPct-1)/5.f)));
}else{
game->SetMosaicEffect(uint8_t(util::lerp(4.f,1.f,(gameSlowdownPct-5)/5.f)));
}
if(gameSlowdownPct<10.f){
if(accTime>=1/60.f*gameSlowdownPct){
game->SetElapsedTime(1/60.f*gameSlowdownPct);
game->HandleUserInput(game->GetElapsedTime());
game->UpdateEffects(game->GetElapsedTime());
GameEvent::UpdateEvents();
game->GetPlayer()->Update(game->GetElapsedTime());
game->UpdateMonsters();
ItemDrop::UpdateDrops(game->GetElapsedTime());
game->UpdateBullets(game->GetElapsedTime());
//game->UpdateCamera(game->GetElapsedTime());
accTime=0.f;
}
}
}
void State_Death::Draw(AiL*game){}

@ -0,0 +1,51 @@
#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
#include "GameState.h"
#include "olcPGEX_ViewPort.h"
class State_Death:public GameState{
protected:
float gameSlowdownPct=1.f;
float accTime=0.f;
float zoom=1.f;
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(AiL*game)override;
virtual void Draw(AiL*game)override;
virtual void OnLevelLoad()override;
};

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 3 #define VERSION_MINOR 3
#define VERSION_PATCH 0 #define VERSION_PATCH 0
#define VERSION_BUILD 7646 #define VERSION_BUILD 7662
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -1061,6 +1061,7 @@ namespace olc
uint32_t GetFPS() const; uint32_t GetFPS() const;
// Gets last update of elapsed time // Gets last update of elapsed time
float GetElapsedTime() const; float GetElapsedTime() const;
void SetElapsedTime(float elapsedTime);
// Returns whether the mouse cursor exists inside the window or outside of it. // Returns whether the mouse cursor exists inside the window or outside of it.
const bool IsMouseInsideWindow() const; const bool IsMouseInsideWindow() const;
// Gets Actual Window pos // Gets Actual Window pos
@ -2269,6 +2270,9 @@ namespace olc
float PixelGameEngine::GetElapsedTime() const float PixelGameEngine::GetElapsedTime() const
{ return fLastElapsed; } { return fLastElapsed; }
void PixelGameEngine::SetElapsedTime(float elapsedTime)
{ fLastElapsed=elapsedTime; }
const bool PixelGameEngine::IsMouseInsideWindow() const const bool PixelGameEngine::IsMouseInsideWindow() const
{ return GetMouseX()>=0&&GetMouseY()>=0&&GetMouseX()<GetScreenSize().x&&GetMouseY()<GetScreenSize().y; } { return GetMouseX()>=0&&GetMouseY()>=0&&GetMouseX()<GetScreenSize().x&&GetMouseY()<GetScreenSize().y; }

Loading…
Cancel
Save