@ -49,7 +49,7 @@ bool Crawler::OnUserCreate(){
//Initialize Camera.
camera = Camera2D { WINDOW_SIZE } ;
camera . SetMode ( olc : : utils : : Camera2D : : Mode : : LazyFollow ) ;
camera . SetTarget ( player . GetPos ( ) ) ;
camera . SetTarget ( player - > GetPos ( ) ) ;
camera . SetWorldBoundary ( { 0 , 0 } , WORLD_SIZE * 24 ) ;
camera . EnableWorldBoundary ( false ) ;
@ -88,7 +88,7 @@ bool Crawler::OnUserCreate(){
LoadLevel ( CAMPAIGN_1_1 ) ;
player . ChangeClass ( WARRIOR ) ;
player - > ChangeClass ( WARRIOR ) ;
return true ;
}
@ -97,7 +97,7 @@ bool Crawler::OnUserUpdate(float fElapsedTime){
fElapsedTime = std : : min ( 1 / 60.f , fElapsedTime ) ;
HandleUserInput ( fElapsedTime ) ;
UpdateEffects ( fElapsedTime ) ;
player . Update ( fElapsedTime ) ;
player - > Update ( fElapsedTime ) ;
for ( Monster & m : MONSTER_LIST ) {
m . Update ( fElapsedTime ) ;
}
@ -139,36 +139,36 @@ void Crawler::HandleUserInput(float fElapsedTime){
ConsoleShow ( F1 ) ;
}
if ( GetMouseWheel ( ) > 0 ) {
switch ( player . cl ) {
switch ( player - > GetClass ( ) ) {
case WARRIOR : {
player . ChangeClass ( RANGER ) ;
player - > ChangeClass ( RANGER ) ;
} break ;
case RANGER : {
player . ChangeClass ( WIZARD ) ;
player - > ChangeClass ( WIZARD ) ;
} break ;
case WIZARD : {
player . ChangeClass ( WARRIOR ) ;
player - > ChangeClass ( WARRIOR ) ;
} break ;
}
}
if ( GetMouseWheel ( ) < 0 ) {
switch ( player . cl ) {
switch ( player - > GetClass ( ) ) {
case WARRIOR : {
player . ChangeClass ( WIZARD ) ;
player - > ChangeClass ( WIZARD ) ;
} break ;
case RANGER : {
player . ChangeClass ( WARRIOR ) ;
player - > ChangeClass ( WARRIOR ) ;
} break ;
case WIZARD : {
player . ChangeClass ( RANGER ) ;
player - > ChangeClass ( RANGER ) ;
} break ;
}
}
if ( player . GetVelocity ( ) = = vf2d { 0 , 0 } & & player . CanMove ( ) ) {
if ( player - > GetVelocity ( ) = = vf2d { 0 , 0 } & & player - > CanMove ( ) ) {
auto GetPlayerStaircaseDirection = [ & ] ( ) {
for ( LayerTag & layer : MAP_DATA [ GetCurrentLevel ( ) ] . LayerData ) {
int truncatedPlayerX = int ( player . GetX ( ) ) / 24 ;
int truncatedPlayerY = int ( player . GetY ( ) ) / 24 ;
int truncatedPlayerX = int ( player - > GetX ( ) ) / 24 ;
int truncatedPlayerY = int ( player - > GetY ( ) ) / 24 ;
int tileID = layer . tiles [ truncatedPlayerY ] [ truncatedPlayerX ] ;
TilesheetData dat = GetTileSheet ( GetCurrentLevel ( ) , tileID ) ;
if ( dat . tileset . staircaseTiles . find ( tileID ) ! = dat . tileset . staircaseTiles . end ( ) ) {
@ -179,133 +179,133 @@ void Crawler::HandleUserInput(float fElapsedTime){
} ;
std : : string staircaseDirection = GetPlayerStaircaseDirection ( ) ;
if ( RightHeld ( ) ) {
player . SetX ( player . GetX ( ) + fElapsedTime * 100 * player . GetMoveSpdMult ( ) ) ;
player - > SetX ( player - > GetX ( ) + fElapsedTime * 100 * player - > GetMoveSpdMult ( ) ) ;
if ( staircaseDirection = = " RIGHT " ) {
player . SetY ( player . GetY ( ) - 60 * fElapsedTime * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) - 60 * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
} else
if ( staircaseDirection = = " LEFT " ) {
player . SetY ( player . GetY ( ) + 60 * fElapsedTime * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) + 60 * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
}
player . SetFacingDirection ( RIGHT ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player . UpdateWalkingAnimation ( RIGHT ) ;
player - > SetFacingDirection ( RIGHT ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
player - > UpdateWalkingAnimation ( RIGHT ) ;
}
setIdleAnimation = false ;
}
if ( LeftHeld ( ) ) {
player . SetX ( player . GetX ( ) - fElapsedTime * 100 * player . GetMoveSpdMult ( ) ) ;
player - > SetX ( player - > GetX ( ) - fElapsedTime * 100 * player - > GetMoveSpdMult ( ) ) ;
if ( staircaseDirection = = " RIGHT " ) {
player . SetY ( player . GetY ( ) + 60 * fElapsedTime * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) + 60 * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
} else
if ( staircaseDirection = = " LEFT " ) {
player . SetY ( player . GetY ( ) - 60 * fElapsedTime * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) - 60 * fElapsedTime * player - > GetMoveSpdMult ( ) ) ;
}
if ( setIdleAnimation ) {
player . SetFacingDirection ( LEFT ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player . UpdateWalkingAnimation ( LEFT ) ;
player - > SetFacingDirection ( LEFT ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
player - > UpdateWalkingAnimation ( LEFT ) ;
}
}
setIdleAnimation = false ;
}
if ( UpHeld ( ) ) {
player . SetY ( player . GetY ( ) - fElapsedTime * 100 * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) - fElapsedTime * 100 * player - > GetMoveSpdMult ( ) ) ;
if ( setIdleAnimation ) {
player . SetFacingDirection ( UP ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player . UpdateWalkingAnimation ( UP ) ;
player - > SetFacingDirection ( UP ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
player - > UpdateWalkingAnimation ( UP ) ;
}
}
setIdleAnimation = false ;
}
if ( DownHeld ( ) ) {
player . SetY ( player . GetY ( ) + fElapsedTime * 100 * player . GetMoveSpdMult ( ) ) ;
player - > SetY ( player - > GetY ( ) + fElapsedTime * 100 * player - > GetMoveSpdMult ( ) ) ;
if ( setIdleAnimation ) {
player . SetFacingDirection ( DOWN ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player . UpdateWalkingAnimation ( DOWN ) ;
player - > SetFacingDirection ( DOWN ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
player - > UpdateWalkingAnimation ( DOWN ) ;
}
}
setIdleAnimation = false ;
}
}
if ( UpReleased ( ) ) {
player . SetLastReleasedMovementKey ( UP ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player - > SetLastReleasedMovementKey ( UP ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
if ( RightHeld ( ) ) {
player . UpdateWalkingAnimation ( RIGHT ) ;
player - > UpdateWalkingAnimation ( RIGHT ) ;
} else
if ( DownHeld ( ) ) {
player . UpdateWalkingAnimation ( DOWN ) ;
player - > UpdateWalkingAnimation ( DOWN ) ;
} else
if ( LeftHeld ( ) ) {
player . UpdateWalkingAnimation ( LEFT ) ;
player - > UpdateWalkingAnimation ( LEFT ) ;
}
}
}
if ( RightReleased ( ) ) {
player . SetLastReleasedMovementKey ( RIGHT ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player - > SetLastReleasedMovementKey ( RIGHT ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
if ( UpHeld ( ) ) {
player . UpdateWalkingAnimation ( UP ) ;
player - > UpdateWalkingAnimation ( UP ) ;
} else
if ( DownHeld ( ) ) {
player . UpdateWalkingAnimation ( DOWN ) ;
player - > UpdateWalkingAnimation ( DOWN ) ;
} else
if ( LeftHeld ( ) ) {
player . UpdateWalkingAnimation ( LEFT ) ;
player - > UpdateWalkingAnimation ( LEFT ) ;
}
}
}
if ( LeftReleased ( ) ) {
player . SetLastReleasedMovementKey ( LEFT ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player - > SetLastReleasedMovementKey ( LEFT ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
if ( RightHeld ( ) ) {
player . UpdateWalkingAnimation ( RIGHT ) ;
player - > UpdateWalkingAnimation ( RIGHT ) ;
} else
if ( DownHeld ( ) ) {
player . UpdateWalkingAnimation ( DOWN ) ;
player - > UpdateWalkingAnimation ( DOWN ) ;
} else
if ( UpHeld ( ) ) {
player . UpdateWalkingAnimation ( UP ) ;
player - > UpdateWalkingAnimation ( UP ) ;
}
}
}
if ( DownReleased ( ) ) {
player . SetLastReleasedMovementKey ( DOWN ) ;
if ( player . GetState ( ) = = State : : NORMAL ) {
player - > SetLastReleasedMovementKey ( DOWN ) ;
if ( player - > GetState ( ) = = State : : NORMAL ) {
if ( RightHeld ( ) ) {
player . UpdateWalkingAnimation ( RIGHT ) ;
player - > UpdateWalkingAnimation ( RIGHT ) ;
} else
if ( UpHeld ( ) ) {
player . UpdateWalkingAnimation ( UP ) ;
player - > UpdateWalkingAnimation ( UP ) ;
} else
if ( LeftHeld ( ) ) {
player . UpdateWalkingAnimation ( LEFT ) ;
player - > UpdateWalkingAnimation ( LEFT ) ;
}
}
}
if ( player . GetState ( ) ! = State : : NORMAL ) {
if ( player - > GetState ( ) ! = State : : NORMAL ) {
setIdleAnimation = false ;
}
if ( setIdleAnimation ) {
switch ( player . GetLastReleasedMovementKey ( ) ) {
switch ( player - > GetLastReleasedMovementKey ( ) ) {
case UP : {
player . UpdateIdleAnimation ( UP ) ;
player - > UpdateIdleAnimation ( UP ) ;
} break ;
case DOWN : {
player . UpdateIdleAnimation ( DOWN ) ;
player - > UpdateIdleAnimation ( DOWN ) ;
} break ;
case LEFT : {
player . UpdateIdleAnimation ( LEFT ) ;
player - > UpdateIdleAnimation ( LEFT ) ;
} break ;
case RIGHT : {
player . UpdateIdleAnimation ( RIGHT ) ;
player - > UpdateIdleAnimation ( RIGHT ) ;
} break ;
default : {
player . UpdateIdleAnimation ( DOWN ) ;
player - > UpdateIdleAnimation ( DOWN ) ;
}
}
}
@ -326,7 +326,7 @@ void Crawler::UpdateCamera(float fElapsedTime){
}
worldShake + = worldShakeVel * fElapsedTime ;
} else {
camera . SetTarget ( player . GetPos ( ) ) ;
camera . SetTarget ( player - > GetPos ( ) ) ;
}
worldShakeTime = std : : max ( 0.f , worldShakeTime - fElapsedTime ) ;
camera . Update ( fElapsedTime ) ;
@ -388,9 +388,9 @@ void Crawler::UpdateBullets(float fElapsedTime){
}
}
} else {
if ( b - > OnUpperLevel ( ) = = player . OnUpperLevel ( ) & & geom2d : : overlaps ( geom2d : : circle ( player . GetPos ( ) , 12 * player . GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player . Hurt ( b - > damage ) ) {
if ( b - > PlayerHit ( player ) ) {
if ( b - > OnUpperLevel ( ) = = player - > OnUpperLevel ( ) & & geom2d : : overlaps ( geom2d : : circle ( player - > GetPos ( ) , 12 * player - > GetSizeMult ( ) / 2 ) , geom2d : : circle ( b - > pos , b - > radius ) ) ) {
if ( player - > Hurt ( b - > damage ) ) {
if ( b - > PlayerHit ( GetPlayer ( ) ) ) {
it = BULLET_LIST . erase ( it ) ;
if ( it = = BULLET_LIST . end ( ) ) {
break ;
@ -431,10 +431,10 @@ void Crawler::HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel){
}
void Crawler : : PopulateRenderLists ( std : : vector < Monster * > & monstersBeforeLower , std : : vector < Monster * > & monstersBeforeUpper , std : : vector < Monster * > & monstersAfterLower , std : : vector < Monster * > & monstersAfterUpper , std : : vector < Bullet * > & bulletsLower , std : : vector < Bullet * > & bulletsUpper , std : : vector < Effect * > & backgroundEffectsLower , std : : vector < Effect * > & backgroundEffectsUpper , std : : vector < Effect * > & foregroundEffectsLower , std : : vector < Effect * > & foregroundEffectsUpper ) {
Player & pl = player ;
Player * pl = GetPlayer ( ) ;
for ( auto it = MONSTER_LIST . begin ( ) ; it ! = MONSTER_LIST . end ( ) ; + + it ) {
Monster & m = * it ;
if ( m . GetPos ( ) . y < pl . GetPos ( ) . y ) { //This monster renders before the player does (behind the player)
if ( m . GetPos ( ) . y < pl - > GetPos ( ) . y ) { //This monster renders before the player does (behind the player)
if ( m . OnUpperLevel ( ) ) {
monstersBeforeUpper . push_back ( & m ) ;
} else {
@ -489,11 +489,11 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( LayerTag & layer : MAP_DATA [ currentLevel ] . LayerData ) {
if ( IsBridgeLayer ( layer ) ) {
bridgeLayer = & layer ;
if ( ! bridgeLayerFade & & ! player . upperLevel ) {
if ( ! bridgeLayerFade & & ! player - > upperLevel ) {
int tileID = layer . tiles [ y ] [ x ] - 1 ;
if ( tileID ! = - 1 ) {
int playerXTruncated = int ( player . GetPos ( ) . x ) / 24 ;
int playerYTruncated = int ( player . GetPos ( ) . y ) / 24 ;
int playerXTruncated = int ( player - > GetPos ( ) . x ) / 24 ;
int playerYTruncated = int ( player - > GetPos ( ) . y ) / 24 ;
if ( playerXTruncated = = x & & playerYTruncated = = y ) {
bridgeLayerFade = true ;
}
@ -534,13 +534,13 @@ void Crawler::RenderWorld(float fElapsedTime){
std : : vector < Monster * > monstersBeforeLower , monstersAfterLower , monstersBeforeUpper , monstersAfterUpper ;
std : : vector < Bullet * > bulletsLower , bulletsUpper ;
std : : vector < Effect * > backgroundEffectsLower , backgroundEffectsUpper , foregroundEffectsLower , foregroundEffectsUpper ;
Player & pl = player ;
Player * pl = GetPlayer ( ) ;
PopulateRenderLists ( monstersBeforeLower , monstersBeforeUpper , monstersAfterLower , monstersAfterUpper , bulletsLower , bulletsUpper , backgroundEffectsLower , backgroundEffectsUpper , foregroundEffectsLower , foregroundEffectsUpper ) ;
if ( player . GetZ ( ) > 0 ) {
vf2d shadowScale = vf2d { 8 / 3.f , 1 } / std : : max ( 1.f , player . GetZ ( ) / 4 ) ;
view . DrawDecal ( player . GetPos ( ) - vf2d { 3 , 3 } * shadowScale / 2 + vf2d { 0 , 6 } , GFX_Circle . Decal ( ) , shadowScale ) ;
if ( player - > GetZ ( ) > 0 ) {
vf2d shadowScale = vf2d { 8 / 3.f , 1 } / std : : max ( 1.f , player - > GetZ ( ) / 4 ) ;
view . DrawDecal ( player - > GetPos ( ) - vf2d { 3 , 3 } * shadowScale / 2 + vf2d { 0 , 6 } , GFX_Circle . Decal ( ) , shadowScale ) ;
}
for ( Effect * e : backgroundEffectsLower ) {
e - > Draw ( ) ;
@ -548,20 +548,20 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Monster * m : monstersBeforeLower ) {
m - > Draw ( ) ;
}
vf2d playerScale = vf2d ( player . GetSizeMult ( ) , player . GetSizeMult ( ) ) ;
vf2d playerPosition = player . GetPos ( ) ;
vf2d playerScale = vf2d ( player - > GetSizeMult ( ) , player - > GetSizeMult ( ) ) ;
vf2d playerPosition = player - > GetPos ( ) ;
# define RENDER_PLAYER \
if ( player . teleportAnimationTimer > 0 ) { \
playerScale . x = 120 * abs ( pow ( player . teleportAnimationTimer - 0.175 , 3 ) ) ; \
playerPosition = player . teleportStartPosition . lerp ( player . teleportTarget , ( 0.35 - player . teleportAnimationTimer ) / 0.35 ) ; \
view . DrawPartialRotatedDecal ( playerPosition + vf2d { 0 , - player . GetZ ( ) } , player . GetFrame ( ) . GetSourceImage ( ) - > Decal ( ) , player . GetSpinAngle ( ) , { 12 , 12 } , player . GetFrame ( ) . GetSourceRect ( ) . pos , player . GetFrame ( ) . GetSourceRect ( ) . size , playerScale , player . GetBuffs ( BuffType : : ATTACK_UP ) . size ( ) > 0 ? Pixel { 255 , uint8_t ( 255 * abs ( sin ( 1.4 * player . GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) , uint8_t ( 255 * abs ( sin ( 1.4 * player . GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) } : WHITE ) ; \
} else { view . DrawPartialRotatedDecal ( playerPosition + vf2d { 0 , - player . GetZ ( ) } , player . GetFrame ( ) . GetSourceImage ( ) - > Decal ( ) , player . GetSpinAngle ( ) , { 12 , 12 } , player . GetFrame ( ) . GetSourceRect ( ) . pos , player . GetFrame ( ) . GetSourceRect ( ) . size , playerScale , player . GetBuffs ( BuffType : : ATTACK_UP ) . size ( ) > 0 ? Pixel { 255 , uint8_t ( 255 * abs ( sin ( 1.4 * player . GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) , uint8_t ( 255 * abs ( sin ( 1.4 * player . GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) } : WHITE ) ; }
if ( player - > teleportAnimationTimer > 0 ) { \
playerScale . x = 120 * abs ( pow ( player - > teleportAnimationTimer - 0.175 , 3 ) ) ; \
playerPosition = player - > teleportStartPosition . lerp ( player - > teleportTarget , ( 0.35 - player - > teleportAnimationTimer ) / 0.35 ) ; \
view . DrawPartialRotatedDecal ( playerPosition + vf2d { 0 , - player - > GetZ ( ) } , player - > GetFrame ( ) . GetSourceImage ( ) - > Decal ( ) , player - > GetSpinAngle ( ) , { 12 , 12 } , player - > GetFrame ( ) . GetSourceRect ( ) . pos , player - > GetFrame ( ) . GetSourceRect ( ) . size , playerScale , player - > GetBuffs ( BuffType : : ATTACK_UP ) . size ( ) > 0 ? Pixel { 255 , uint8_t ( 255 * abs ( sin ( 1.4 * player - > GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) , uint8_t ( 255 * abs ( sin ( 1.4 * player - > GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) } : WHITE ) ; \
} else { view . DrawPartialRotatedDecal ( playerPosition + vf2d { 0 , - player - > GetZ ( ) } , player - > GetFrame ( ) . GetSourceImage ( ) - > Decal ( ) , player - > GetSpinAngle ( ) , { 12 , 12 } , player - > GetFrame ( ) . GetSourceRect ( ) . pos , player - > GetFrame ( ) . GetSourceRect ( ) . size , playerScale , player - > GetBuffs ( BuffType : : ATTACK_UP ) . size ( ) > 0 ? Pixel { 255 , uint8_t ( 255 * abs ( sin ( 1.4 * player - > GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) , uint8_t ( 255 * abs ( sin ( 1.4 * player - > GetBuffs ( BuffType : : ATTACK_UP ) [ 0 ] . duration ) ) ) } : WHITE ) ; }
//define end
if ( ! player . upperLevel ) {
if ( ! player - > upperLevel ) {
RENDER_PLAYER
}
if ( player . GetState ( ) = = State : : BLOCK ) {
view . DrawDecal ( player . GetPos ( ) - vf2d { 12 , 12 } , GFX_BLOCK_BUBBLE . Decal ( ) ) ;
if ( player - > GetState ( ) = = State : : BLOCK ) {
view . DrawDecal ( player - > GetPos ( ) - vf2d { 12 , 12 } , GFX_BLOCK_BUBBLE . Decal ( ) ) ;
}
for ( Monster * m : monstersAfterLower ) {
m - > Draw ( ) ;
@ -575,7 +575,7 @@ void Crawler::RenderWorld(float fElapsedTime){
# pragma region Foreground Rendering
for ( TileGroup & group : foregroundTileGroups ) {
if ( view . IsRectVisible ( group . GetRange ( ) . pos , group . GetRange ( ) . size ) ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player . pos ) ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player - > pos ) ) {
group . playerBehind = true ;
group . fadeFactor = std : : min ( group . fadeFactor + fElapsedTime , TileGroup : : FADE_TIME ) ;
} else {
@ -621,7 +621,7 @@ void Crawler::RenderWorld(float fElapsedTime){
for ( Monster * m : monstersBeforeUpper ) {
m - > Draw ( ) ;
}
if ( player . upperLevel ) {
if ( player - > upperLevel ) {
RENDER_PLAYER
}
for ( Monster * m : monstersAfterUpper ) {
@ -635,7 +635,7 @@ void Crawler::RenderWorld(float fElapsedTime){
}
# pragma region Upper Foreground Rendering
for ( TileGroup & group : upperForegroundTileGroups ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player . pos ) ) {
if ( geom2d : : overlaps ( group . GetFadeRange ( ) , player - > pos ) ) {
group . playerBehind = true ;
group . fadeFactor = std : : min ( group . fadeFactor + fElapsedTime , TileGroup : : FADE_TIME ) ;
} else {
@ -665,8 +665,8 @@ void Crawler::RenderWorld(float fElapsedTime){
}
}
Player & Crawler : : GetPlayer ( ) {
return player ;
Player * Crawler : : GetPlayer ( ) {
return player . get ( ) ;
}
void Crawler : : RenderHud ( ) {
@ -679,10 +679,10 @@ void Crawler::RenderHud(){
return newName ;
} ;
std : : vector < Ability > cooldowns {
player . rightClickAbility ,
player . ability1 ,
player . ability2 ,
player . ability3
player - > rightClickAbility ,
player - > ability1 ,
player - > ability2 ,
player - > ability3
} ;
std : : vector < Ability > activeCooldowns ;
std : : copy_if ( cooldowns . begin ( ) , cooldowns . end ( ) , std : : back_inserter ( activeCooldowns ) , [ ] ( Ability a ) {
@ -706,23 +706,23 @@ void Crawler::RenderHud(){
}
DrawDecal ( { 2 , 2 } , GFX_Heart . Decal ( ) ) ;
DrawDecal ( { 2 , 20 } , GFX_Mana . Decal ( ) ) ;
std : : string text = player . GetHealth ( ) > 0 ? std : : to_string ( player . GetHealth ( ) ) : " X " ;
std : : string text_mana = std : : to_string ( player . GetMana ( ) ) ;
std : : string text = player - > GetHealth ( ) > 0 ? std : : to_string ( player - > GetHealth ( ) ) : " X " ;
std : : string text_mana = std : : to_string ( player - > GetMana ( ) ) ;
DrawShadowStringPropDecal ( { 20 , 3 } , text , WHITE , BLACK , { 2 , 2 } ) ;
DrawShadowStringPropDecal ( { 24 , 23 } , text_mana , { 192 , 192 , 255 } , BLACK , { 1.5 , 1.5 } ) ;
if ( player . notEnoughManaDisplay . second > 0 ) {
std : : string displayText = " Not enough mana for " + player . notEnoughManaDisplay . first + " ! " ;
if ( player - > notEnoughManaDisplay . second > 0 ) {
std : : string displayText = " Not enough mana for " + player - > notEnoughManaDisplay . first + " ! " ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) } - GetTextSizeProp ( displayText ) / 2 , displayText , DARK_RED , VERY_DARK_RED ) ;
}
if ( player . notificationDisplay . second > 0 ) {
std : : string displayText = player . notificationDisplay . first ;
if ( player - > notificationDisplay . second > 0 ) {
std : : string displayText = player - > notificationDisplay . first ;
DrawShadowStringPropDecal ( vf2d { float ( ScreenWidth ( ) / 2 ) , float ( ScreenHeight ( ) / 4 ) - 24 } - GetTextSizeProp ( displayText ) / 2 , displayText , BLUE , VERY_DARK_BLUE ) ;
}
std : : string versionStr ( " v " + std : : to_string ( VERSION_MAJOR ) + " . " + std : : to_string ( VERSION_MINOR ) + " . " + std : : to_string ( VERSION_PATCH ) + " . " + std : : to_string ( VERSION_BUILD ) ) ;
DrawShadowStringDecal ( vf2d { GetScreenSize ( ) } - vf2d { GetTextSize ( versionStr ) } * 0.4 , versionStr , WHITE , BLACK , { 0.4 , 0.4 } , 0.4 ) ;
# ifdef DEBUG_POS
DrawShadowStringDecal ( { 0 , 128 } , player . GetPos ( ) . str ( ) ) ;
DrawShadowStringDecal ( { 0 , 128 } , player - > GetPos ( ) . str ( ) ) ;
# endif
}
@ -745,7 +745,7 @@ vf2d Crawler::GetWorldMousePos(){
void Crawler : : SetupWorldShake ( float duration ) {
worldShakeTime = duration ;
worldShake = player . GetPos ( ) ;
worldShake = player - > GetPos ( ) ;
camera . SetTarget ( worldShake ) ;
}
@ -878,8 +878,8 @@ void Crawler::LoadLevel(MapName map){
}
counter + + ;
}
player . upperLevel = false ; //Assume player starts on lower level.
player . SetPos ( MAP_DATA [ map ] . MapData . playerSpawnLocation ) ;
player - > upperLevel = false ; //Assume player starts on lower level.
player - > SetPos ( MAP_DATA [ map ] . MapData . playerSpawnLocation ) ;
pathfinder . Initialize ( ) ;
}
@ -969,6 +969,30 @@ std::map<std::string,std::vector<geom2d::rect<int>>>&Crawler::GetZoneData(MapNam
return MAP_DATA [ map ] . ZoneData ;
}
void Crawler : : ChangePlayerClass ( Class cl ) {
switch ( cl ) {
case WARRIOR : {
player . reset ( new Warrior ( ) ) ;
} break ;
case THIEF : {
player . reset ( new Thief ( ) ) ;
} break ;
case TRAPPER : {
player . reset ( new Trapper ( ) ) ;
} break ;
case RANGER : {
player . reset ( new Ranger ( ) ) ;
} break ;
case WIZARD : {
player . reset ( new Wizard ( ) ) ;
} break ;
case WITCH : {
player . reset ( new Witch ( ) ) ;
} break ;
}
GetPlayer ( ) - > UpdateIdleAnimation ( DOWN ) ;
}
int main ( )
{
Crawler demo ;