@ -229,6 +229,8 @@ bool AiL::OnUserCreate(){
Inventory : : AddItem ( " Shell Sword " ) ;
Inventory : : AddItem ( " Shell Sword " ) ;
Inventory : : AddItem ( " Ring of the Slime King " , 3 ) ;
Inventory : : AddItem ( " Ring of the Slime King " , 3 ) ;
Audio : : Initialize ( ) ;
LoadLevel ( LEVEL_NAMES [ " starting_map " _S ] ) ;
LoadLevel ( LEVEL_NAMES [ " starting_map " _S ] ) ;
ChangePlayerClass ( WARRIOR ) ;
ChangePlayerClass ( WARRIOR ) ;
@ -243,8 +245,6 @@ bool AiL::OnUserCreate(){
Stats : : InitializeDamageReductionTable ( ) ;
Stats : : InitializeDamageReductionTable ( ) ;
Audio : : Initialize ( ) ;
utils : : datafile : : INITIAL_SETUP_COMPLETE = true ;
utils : : datafile : : INITIAL_SETUP_COMPLETE = true ;
ValidateGameStatus ( ) ; //Checks to make sure everything has been initialized properly.
ValidateGameStatus ( ) ; //Checks to make sure everything has been initialized properly.
@ -851,6 +851,7 @@ void AiL::RenderWorld(float fElapsedTime){
if ( ! IsForegroundTile ( tileSheet , tileSheetIndex ) & & ! IsUpperForegroundTile ( tileSheetIndex ) & & ! IsReflectiveTile ( tileSheet , tileSheetIndex ) ) {
if ( ! IsForegroundTile ( tileSheet , tileSheetIndex ) & & ! IsUpperForegroundTile ( tileSheetIndex ) & & ! IsReflectiveTile ( tileSheet , tileSheetIndex ) ) {
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
@ -858,6 +859,7 @@ void AiL::RenderWorld(float fElapsedTime){
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
}
}
# endif
}
}
}
}
}
}
@ -877,6 +879,7 @@ void AiL::RenderWorld(float fElapsedTime){
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
if ( layer . tag . data [ " class " ] ! = " CollisionOnly " ) { visibleTiles . erase ( { x , y } ) ; }
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
RenderTile ( { x , y } , tileSheet , tileSheetIndex , { tileSheetX , tileSheetY } ) ;
}
}
# ifdef _DEBUG
if ( " debug_collision_boxes " _I ) {
if ( " debug_collision_boxes " _I ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
if ( tileSheet . tileset - > collision . find ( tileSheetIndex ) ! = tileSheet . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
geom2d : : rect < int > collision = tileSheet . tileset - > collision [ tileSheetIndex ] . collision ;
@ -884,6 +887,7 @@ void AiL::RenderWorld(float fElapsedTime){
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
view . DrawRectDecal ( vi2d { x , y } * GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
}
}
# endif
}
}
}
}
} break ;
} break ;
@ -1061,12 +1065,14 @@ void AiL::RenderWorld(float fElapsedTime){
int tileSheetX = tileSheetIndex % tileSheetWidth ;
int tileSheetX = tileSheetIndex % tileSheetWidth ;
int tileSheetY = 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 ) } ) ;
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
# ifdef _DEBUG
if ( tileSheet . tileset . collision . find ( tileSheetIndex ) ! = tileSheet . tileset . collision . end ( ) ) {
if ( " debug_collision_boxes " _I ) {
geom2d : : rect < int > collision = tileSheet . tileset . collision [ tileSheetIndex ] . collision ;
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 . 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 ) ;
view . DrawRectDecal ( vi2d { x , y } * game - > GetCurrentMap ( ) . tilewidth + collision . pos , collision . size , GREY ) ;
}
}
}
# endif
# endif
}
}
}
}
@ -1241,12 +1247,14 @@ void AiL::RenderWorld(float fElapsedTime){
}
}
}
}
# ifdef _DEBUG
if ( DEBUG_PATHFINDING ) {
if ( DEBUG_PATHFINDING ) {
std : : vector < vf2d > pathing = game - > pathfinder . Solve_AStar ( player . get ( ) - > GetPos ( ) , GetWorldMousePos ( ) , 8 , player . get ( ) - > OnUpperLevel ( ) ) ;
std : : vector < vf2d > pathing = game - > pathfinder . Solve_AStar ( player . get ( ) - > GetPos ( ) , GetWorldMousePos ( ) , 8 , player . get ( ) - > OnUpperLevel ( ) ) ;
for ( vf2d & square : pathing ) {
for ( vf2d & square : pathing ) {
view . FillRectDecal ( square * float ( game - > GetCurrentMap ( ) . tilewidth ) , { float ( game - > GetCurrentMap ( ) . tilewidth ) , float ( game - > GetCurrentMap ( ) . tilewidth ) } , DARK_GREEN ) ;
view . FillRectDecal ( square * float ( game - > GetCurrentMap ( ) . tilewidth ) , { float ( game - > GetCurrentMap ( ) . tilewidth ) , float ( game - > GetCurrentMap ( ) . tilewidth ) } , DARK_GREEN ) ;
}
}
}
}
# endif
}
}
Player * AiL : : GetPlayer ( ) {
Player * AiL : : GetPlayer ( ) {
@ -1293,6 +1301,7 @@ void AiL::RenderHud(){
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) - 24 } - GetTextSizeProp ( displayText ) / 2 , displayText , BLUE , VERY_DARK_BLUE ) ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) - 24 } - GetTextSizeProp ( displayText ) / 2 , displayText , BLUE , VERY_DARK_BLUE ) ;
}
}
DisplayBossEncounterInfo ( ) ;
DisplayBossEncounterInfo ( ) ;
# ifdef _DEBUG
if ( " debug_player_info " _I ) {
if ( " debug_player_info " _I ) {
DrawShadowStringDecal ( { 0 , 128 } , player - > GetPos ( ) . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 128 } , player - > GetPos ( ) . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 136 } , " Spd: " + std : : to_string ( player - > GetMoveSpdMult ( ) ) ) ;
DrawShadowStringDecal ( { 0 , 136 } , " Spd: " + std : : to_string ( player - > GetMoveSpdMult ( ) ) ) ;
@ -1303,7 +1312,9 @@ void AiL::RenderHud(){
}
}
DrawShadowStringDecal ( { 0 , 1 } , " Selection: " + Menu : : menus [ INVENTORY_CONSUMABLES ] - > selection . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 1 } , " Selection: " + Menu : : menus [ INVENTORY_CONSUMABLES ] - > selection . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 12 } , " Button Hold Time: " + std : : to_string ( Menu : : menus [ INVENTORY_CONSUMABLES ] - > buttonHoldTime ) ) ;
DrawShadowStringDecal ( { 0 , 12 } , " Button Hold Time: " + std : : to_string ( Menu : : menus [ INVENTORY_CONSUMABLES ] - > buttonHoldTime ) ) ;
} }
}
# endif
}
void AiL : : RenderCooldowns ( ) {
void AiL : : RenderCooldowns ( ) {
std : : vector < Ability > cooldowns {
std : : vector < Ability > cooldowns {
@ -1784,6 +1795,12 @@ void AiL::LoadLevel(MapName map){
camera . MoveCamera ( cameraStartPos ) ;
camera . MoveCamera ( cameraStartPos ) ;
pathfinder . Initialize ( ) ;
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 ) {
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 ) {
void AiL : : OutputDebugInfo ( const char * key , std : : size_t len ) {
# ifdef _DEBUG
if ( utils : : datafile : : DEBUG_ACCESS_OPTIONS ) {
if ( utils : : datafile : : DEBUG_ACCESS_OPTIONS ) {
std : : string k = std : : string ( key ) ;
std : : string k = std : : string ( key ) ;
if ( ! k . starts_with ( " debug_ " ) ) {
if ( ! k . starts_with ( " debug_ " ) ) {
std : : cout < < " Reading " < < k < < std : : endl ;
std : : cout < < " Reading " < < k < < std : : endl ;
}
}
}
}
# endif
}
}
bool AiL : : IsReflectiveTile ( TilesheetData tileSheet , int tileID ) {
bool AiL : : IsReflectiveTile ( TilesheetData tileSheet , int tileID ) {
@ -2473,6 +2492,9 @@ void AiL::ClearLoadoutItem(int slot){
}
}
void AiL : : RenderFadeout ( ) {
void AiL : : RenderFadeout ( ) {
if ( Audio : : BGMFullyLoaded ( ) ) {
game - > DisableFadeIn ( false ) ;
}
uint8_t alpha = 0 ;
uint8_t alpha = 0 ;
if ( fadeOutDuration > 0 ) {
if ( fadeOutDuration > 0 ) {
fadeOutDuration = std : : max ( 0.f , fadeOutDuration - GetElapsedTime ( ) ) ;
fadeOutDuration = std : : max ( 0.f , fadeOutDuration - GetElapsedTime ( ) ) ;
@ -2482,14 +2504,26 @@ void AiL::RenderFadeout(){
alpha = uint8_t ( util : : lerp ( 0 , 255 , 1 - ( fadeOutDuration / fadeOutTotalTime ) ) ) ;
alpha = uint8_t ( util : : lerp ( 0 , 255 , 1 - ( fadeOutDuration / fadeOutTotalTime ) ) ) ;
} else
} else
if ( fadeInDuration > 0 ) {
if ( fadeInDuration > 0 ) {
if ( ! disableFadeIn ) {
fadeInDuration = std : : max ( 0.f , fadeInDuration - GetElapsedTime ( ) ) ;
fadeInDuration = std : : max ( 0.f , fadeInDuration - GetElapsedTime ( ) ) ;
alpha = uint8_t ( util : : lerp ( 255 , 0 , 1 - ( fadeInDuration / fadeOutTotalTime ) ) ) ;
alpha = uint8_t ( util : : lerp ( 255 , 0 , 1 - ( fadeInDuration / fadeOutTotalTime ) ) ) ;
} else {
alpha = 255 ;
}
}
}
FillRectDecal ( { 0 , 0 } , GetScreenSize ( ) , { 0 , 0 , 0 , alpha } ) ;
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 ( ) {
bool AiL : : GamePaused ( ) {
return fadeOutDuration > 0 ;
return fadeOutDuration > 0 | | disableFadeIn ;
}
}
void AiL : : EndGame ( ) {
void AiL : : EndGame ( ) {
@ -2586,3 +2620,7 @@ std::string operator ""_FS(const char*key,std::size_t len){
AiL : : OutputDebugInfo ( key , len ) ;
AiL : : OutputDebugInfo ( key , len ) ;
return DATA . GetProperty ( std : : string ( key , len ) ) . GetFullString ( ) ;
return DATA . GetProperty ( std : : string ( key , len ) ) . GetFullString ( ) ;
}
}
void AiL : : DisableFadeIn ( const bool disable ) {
disableFadeIn = disable ;
}