@ -229,6 +229,8 @@ bool AiL::OnUserCreate(){
Inventory : : AddItem ( " Shell Sword " ) ;
Inventory : : AddItem ( " Ring of the Slime King " , 3 ) ;
Audio : : Initialize ( ) ;
LoadLevel ( LEVEL_NAMES [ " starting_map " _S ] ) ;
ChangePlayerClass ( WARRIOR ) ;
@ -243,8 +245,6 @@ bool AiL::OnUserCreate(){
Stats : : InitializeDamageReductionTable ( ) ;
Audio : : Initialize ( ) ;
utils : : datafile : : INITIAL_SETUP_COMPLETE = true ;
ValidateGameStatus ( ) ; //Checks to make sure everything has been initialized properly.
@ -851,13 +851,15 @@ void AiL::RenderWorld(float fElapsedTime){
if ( ! IsForegroundTile ( tileSheet , tileSheetIndex ) & & ! IsUpperForegroundTile ( tileSheetIndex ) & & ! IsReflectiveTile ( tileSheet , tileSheetIndex ) ) {
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
}
# endif
}
}
}
@ -877,13 +879,15 @@ void AiL::RenderWorld(float fElapsedTime){
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
}
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
}
# endif
}
}
} break ;
@ -1061,11 +1065,13 @@ void AiL::RenderWorld(float fElapsedTime){
int tileSheetX = tileSheetIndex % tileSheetWidth ;
int tileSheetY = tileSheetIndex / tileSheetWidth ;
view . DrawPartialDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth , { float ( tileSheet . tileset - > tilewidth ) , float ( tileSheet . tileset - > tileheight ) } , tileSheet . tileset - > tileset - > Decal ( ) , vi2d { tileSheetX , tileSheetY } * game - > GetCurrentMap ( ) . tilewidth , { float ( tileSheet . tileset - > tilewidth ) , float ( tileSheet . tileset - > tileheight ) } , { 255 , 255 , 255 , uint8_t ( 255 - bridgeFadeFactor / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
# ifdef DEBUG_COLLISIONS
if ( tileSheet . tileset . collision . find ( tileSheetIndex ) ! = tileSheet . tileset . collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset . collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
view . FillRectDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , { 0 , 0 , 0 , 128 } ) ;
view . DrawRectDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
# endif
}
@ -1241,12 +1247,14 @@ void AiL::RenderWorld(float fElapsedTime){
}
}
if ( DEBUG_PATHFINDING ) {
std : : vector < vf2d > pathing = game - > pathfinder . Solve_AStar ( player . get ( ) - > GetPos ( ) , GetWorldMousePos ( ) , 8 , player . get ( ) - > OnUpperLevel ( ) ) ;
for ( vf2d & square : pathing ) {
view . FillRectDecal ( square * float ( game - > GetCurrentMap ( ) . tilewidth ) , { float ( game - > GetCurrentMap ( ) . tilewidth ) , float ( game - > GetCurrentMap ( ) . tilewidth ) } , DARK_GREEN ) ;
# ifdef _DEBUG
if ( DEBUG_PATHFINDING ) {
std : : vector < vf2d > pathing = game - > pathfinder . Solve_AStar ( player . get ( ) - > GetPos ( ) , GetWorldMousePos ( ) , 8 , player . get ( ) - > OnUpperLevel ( ) ) ;
for ( vf2d & square : pathing ) {
view . FillRectDecal ( square * float ( game - > GetCurrentMap ( ) . tilewidth ) , { float ( game - > GetCurrentMap ( ) . tilewidth ) , float ( game - > GetCurrentMap ( ) . tilewidth ) } , DARK_GREEN ) ;
}
}
}
# endif
}
Player * AiL : : GetPlayer ( ) {
@ -1293,17 +1301,20 @@ void AiL::RenderHud(){
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) - 24 } - GetTextSizeProp ( displayText ) / 2 , displayText , BLUE , VERY_DARK_BLUE ) ;
}
DisplayBossEncounterInfo ( ) ;
if ( " debug_player_info " _I ) {
DrawShadowStringDecal ( { 0 , 128 } , player - > GetPos ( ) . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 136 } , " Spd: " + std : : to_string ( player - > GetMoveSpdMult ( ) ) ) ;
DrawShadowStringDecal ( { 0 , 144 } , " HP Timer: " + std : : to_string ( player - > hpRecoveryTimer ) ) ;
DrawShadowStringDecal ( { 0 , 152 } , " HP Recovery Amt: " + std : : to_string ( player - > GetHPRecoveryPct ( ) * player - > GetMaxHealth ( ) ) ) ;
if ( ! ISBLANK ( GetLoadoutItem ( 0 ) ) ) {
DrawShadowStringDecal ( { 0 , 92 } , " Loadout Slot 1 Qty: " + std : : to_string ( GetLoadoutItem ( 0 ) . lock ( ) - > Amt ( ) ) ) ;
}
DrawShadowStringDecal ( { 0 , 1 } , " Selection: " + Menu : : menus [ INVENTORY_CONSUMABLES ] - > selection . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 12 } , " Button Hold Time: " + std : : to_string ( Menu : : menus [ INVENTORY_CONSUMABLES ] - > buttonHoldTime ) ) ;
} }
# ifdef _DEBUG
if ( " debug_player_info " _I ) {
DrawShadowStringDecal ( { 0 , 128 } , player - > GetPos ( ) . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 136 } , " Spd: " + std : : to_string ( player - > GetMoveSpdMult ( ) ) ) ;
DrawShadowStringDecal ( { 0 , 144 } , " HP Timer: " + std : : to_string ( player - > hpRecoveryTimer ) ) ;
DrawShadowStringDecal ( { 0 , 152 } , " HP Recovery Amt: " + std : : to_string ( player - > GetHPRecoveryPct ( ) * player - > GetMaxHealth ( ) ) ) ;
if ( ! ISBLANK ( GetLoadoutItem ( 0 ) ) ) {
DrawShadowStringDecal ( { 0 , 92 } , " Loadout Slot 1 Qty: " + std : : to_string ( GetLoadoutItem ( 0 ) . lock ( ) - > Amt ( ) ) ) ;
}
DrawShadowStringDecal ( { 0 , 1 } , " Selection: " + Menu : : menus [ INVENTORY_CONSUMABLES ] - > selection . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 12 } , " Button Hold Time: " + std : : to_string ( Menu : : menus [ INVENTORY_CONSUMABLES ] - > buttonHoldTime ) ) ;
}
# endif
}
void AiL : : RenderCooldowns ( ) {
std : : vector < Ability > cooldowns {
@ -1784,6 +1795,12 @@ void AiL::LoadLevel(MapName map){
camera . MoveCamera ( cameraStartPos ) ;
pathfinder . Initialize ( ) ;
Audio : : SetAudioEvent ( " Default Volume " ) ;
game - > audioEngine . fullyLoaded = true ; //We assume there's no audio to load, so we just set the audio as fully loaded by default.
if ( MAP_DATA [ map ] . bgmSongName . length ( ) > 0 ) {
Audio : : PlayBGM ( MAP_DATA [ map ] . bgmSongName ) ;
DisableFadeIn ( true ) ;
}
}
bool AiL : : IsUpperForegroundTile ( int tileID ) {
@ -2075,12 +2092,14 @@ datafile operator ""_A(const char*key,std::size_t len){
}
void AiL : : OutputDebugInfo ( const char * key , std : : size_t len ) {
if ( utils : : datafile : : DEBUG_ACCESS_OPTIONS ) {
std : : string k = std : : string ( key ) ;
if ( ! k . starts_with ( " debug_ " ) ) {
std : : cout < < " Reading " < < k < < std : : endl ;
# ifdef _DEBUG
if ( utils : : datafile : : DEBUG_ACCESS_OPTIONS ) {
std : : string k = std : : string ( key ) ;
if ( ! k . starts_with ( " debug_ " ) ) {
std : : cout < < " Reading " < < k < < std : : endl ;
}
}
}
# endif
}
bool AiL : : IsReflectiveTile ( TilesheetData tileSheet , int tileID ) {
@ -2473,6 +2492,9 @@ void AiL::ClearLoadoutItem(int slot){
}
void AiL : : RenderFadeout ( ) {
if ( Audio : : BGMFullyLoaded ( ) ) {
game - > DisableFadeIn ( false ) ;
}
uint8_t alpha = 0 ;
if ( fadeOutDuration > 0 ) {
fadeOutDuration = std : : max ( 0.f , fadeOutDuration - GetElapsedTime ( ) ) ;
@ -2482,14 +2504,26 @@ void AiL::RenderFadeout(){
alpha = uint8_t ( util : : lerp ( 0 , 255 , 1 - ( fadeOutDuration / fadeOutTotalTime ) ) ) ;
} else
if ( fadeInDuration > 0 ) {
fadeInDuration = std : : max ( 0.f , fadeInDuration - GetElapsedTime ( ) ) ;
alpha = uint8_t ( util : : lerp ( 255 , 0 , 1 - ( fadeInDuration / fadeOutTotalTime ) ) ) ;
if ( ! disableFadeIn ) {
fadeInDuration = std : : max ( 0.f , fadeInDuration - GetElapsedTime ( ) ) ;
alpha = uint8_t ( util : : lerp ( 255 , 0 , 1 - ( fadeInDuration / fadeOutTotalTime ) ) ) ;
} else {
alpha = 255 ;
}
}
FillRectDecal ( { 0 , 0 } , GetScreenSize ( ) , { 0 , 0 , 0 , alpha } ) ;
# ifdef _DEBUG
if ( " debug_transition_info " _I ) {
DrawShadowStringDecal ( { 2 , 2 } , " Alpha: " + std : : to_string ( alpha ) ) ;
DrawShadowStringDecal ( { 2 , 14 } , " Disable Fade In: " + std : : to_string ( disableFadeIn ) ) ;
DrawShadowStringDecal ( { 2 , 26 } , " Fully Loaded: " + std : : to_string ( audioEngine . fullyLoaded ) ) ;
}
# endif
}
bool AiL : : GamePaused ( ) {
return fadeOutDuration > 0 ;
return fadeOutDuration > 0 | | disableFadeIn ;
}
void AiL : : EndGame ( ) {
@ -2585,4 +2619,8 @@ void AiL::OnRequestCompleted(const std::string_view receivedData)const{
std : : string operator " " _FS ( const char * key , std : : size_t len ) {
AiL : : OutputDebugInfo ( key , len ) ;
return DATA . GetProperty ( std : : string ( key , len ) ) . GetFullString ( ) ;
}
void AiL : : DisableFadeIn ( const bool disable ) {
disableFadeIn = disable ;
}