@ -53,7 +53,7 @@ class DisplayNumber{
public :
int number ; //Negative means healing.
int frame ; //Frame it was created.
in t x , y ;
floa t x , y ;
int alpha = 255 ;
DisplayNumber ( int numb , int x , int y , int frameCount ) {
this - > number = numb ;
@ -128,6 +128,7 @@ class WEATHER_POWER{
this - > range = range ;
this - > bgcol = bgcol ;
this - > textcol = textcol ;
this - > effectTime = effectTime ;
}
} ;
@ -255,7 +256,7 @@ public:
int PLAYER_HP = PLAYER_MAXHP ;
int BATTLE_CURRENT_TURN_ENTITY = - 1 ;
int CURRENT_ENCOUNTER_IND = - 1 ;
std : : vector < DisplayNumber > BATTLE_DISPLAY_NUMBERS ;
std : : vector < DisplayNumber * > BATTLE_DISPLAY_NUMBERS ;
std : : vector < WEATHER_POWER * > MOVESET_SPIDEY ;
@ -759,15 +760,13 @@ public:
}
for ( int i = 0 ; i < BATTLE_DISPLAY_NUMBERS . size ( ) ; i + + ) {
DisplayNumber * numb = & BATTLE_DISPLAY_NUMBERS [ i ] ;
DisplayNumber * numb = BATTLE_DISPLAY_NUMBERS [ i ] ;
if ( frameCount - numb - > frame > 60 ) {
delete numb ;
BATTLE_DISPLAY_NUMBERS . erase ( BATTLE_DISPLAY_NUMBERS . begin ( ) + i - - ) ;
delete numb ;
} else {
if ( frameCount % 8 = = 0 ) {
numb - > y - - ;
numb - > alpha - = 255 / 8 ;
}
numb - > y - = 0.01 ;
numb - > alpha - = 4 ;
}
}
@ -822,14 +821,14 @@ public:
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
effectRadius ( { PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] } , ref , true ) ;
} else {
effectRadius ( { CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . x , CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . y } , ref , false ) ;
effectRadius ( { CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . x + CURRENT_ENCOUNTER . x , CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . y + CURRENT_ENCOUNTER . y } , ref , false ) ;
}
} else
if ( EFFECT_TIMER = = ref - > effectTime - 10 ) {
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
effectRadius ( { PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] } , ref , true ) ;
effectRadius ( { CURRENT_ENCOUNTER . entities [ PLAYER_SELECTED_TARGET ] . x + CURRENT_ENCOUNTER . x , CURRENT_ENCOUNTER . entities [ PLAYER_SELECTED_TARGET ] . y + CURRENT_ENCOUNTER . y } , ref , true ) ;
} else {
effectRadius ( { CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . x , CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . y } , ref , false ) ;
effectRadius ( { PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] } , ref , false ) ;
}
}
if ( EFFECT_TIMER > ref - > effectTime ) {
@ -840,6 +839,7 @@ public:
case battle : : DAMAGE_RESOLUTION : {
EFFECT_TIMER + + ;
if ( EFFECT_TIMER > 60 ) {
std : : cout < < " In here: " < < EFFECT_TIMER < < " \n " ;
if ( turnOrder . empty ( ) ) {
bool allDead = true ;
for ( auto & ent : CURRENT_ENCOUNTER . entities ) {
@ -854,6 +854,9 @@ public:
BATTLE_CARD_SELECTION_IND = 0 ;
PLAYER_SELECTED_TARGET = - 1 ;
BATTLE_STATE = battle : : NONE ;
} else {
BATTLE_STATE = battle : : PLAYER_SELECTION ;
PLAYER_SELECTED_TARGET = - 1 ;
}
} else {
BATTLE_CURRENT_TURN_ENTITY = turnOrder . top ( ) ;
@ -1056,21 +1059,29 @@ public:
DrawStringDecal ( { WIDTH - GetTextSize ( " <UP> Back " ) . x - 2 , HEIGHT - GetTextSize ( " <UP> Back " ) . y - 2 } , " <UP> Back " , GREEN , { 1 , 1 } ) ;
}
} break ;
case battle : : WAIT_TURN_ANIMATION : {
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
DrawWrappedText ( { 4 , 4 } , " Player uses " + BATTLE_CARD_SELECTION - > name , WIDTH - 8 , WHITE , { 2 , 2 } ) ;
} else {
DrawWrappedText ( { 4 , 4 } , CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . name + " " + ( char ) ( ' A ' + BATTLE_CURRENT_TURN_ENTITY ) + " with " + CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . selectedMove - > name , WIDTH - 8 , WHITE , { 2 , 2 } ) ;
}
} break ;
}
if ( IN_BATTLE_ENCOUNTER | | ( ! CUTSCENE_ACTIVE & & PLAYER_HP ! = PLAYER_MAXHP ) ) {
DrawStringDecal ( { 4 + 1 , HEIGHT - 10 - GetTextSize ( " HP: " ) . y + 1 } , " HP: " + std : : to_string ( PLAYER_HP ) , BLACK ) ;
DrawStringDecal ( { 4 , HEIGHT - 10 - GetTextSize ( " HP: " ) . y } , " HP: " + std : : to_string ( PLAYER_HP ) ) ;
DrawHealthbar ( { 2 , HEIGHT - 10 } , WIDTH / 2 , PLAYER_HP / PLAYER_MAXHP , BLACK ) ;
for ( auto & numb : BATTLE_DISPLAY_NUMBERS ) {
std : : string display = ( ( numb . number > 0 ) ? " - " + std : : to_string ( numb . number ) : " + " + std : : to_string ( numb . number * - 1 ) ) ;
std : : string display = ( ( numb - > number > 0 ) ? " - " + std : : to_string ( numb - > number ) : " + " + std : : to_string ( numb - > number * - 1 ) ) ;
for ( int x = - 1 ; x < = 1 ; x + + ) {
for ( int y = - 1 ; y < = 1 ; y + + ) {
if ( x ! = 0 & & y ! = 0 ) {
DrawStringDecal ( { numb . x - GetTextSize ( display ) . x / 2 + x , numb . y - 8 - GetTextSize ( display ) . y / 2 + y } , display , ( numb . number > 0 ) ? Pixel ( 255 , 0 , 0 , numb . alpha ) : Pixel ( 0 , 255 , 0 , numb . alpha ) , { 2 , 2 } ) ;
DrawStringDecal ( { ( ( numb - > x - PLAYER_COORDS [ 0 ] ) * 32 + WIDTH / 2 ) - GetTextSize ( display ) . x / 2 + x , ( ( numb - > y - PLAYER_COORDS [ 1 ] ) * 32 + HEIGHT / 2 ) - 8 - GetTextSize ( display ) . y / 2 + y } , display , ( numb - > number > 0 ) ? Pixel ( 255 , 0 , 0 , numb - > alpha ) : Pixel ( 0 , 255 , 0 , numb - > alpha ) , { 2 , 2 } ) ;
}
}
}
DrawStringDecal ( { numb . x - GetTextSize ( display ) . x / 2 , numb . y - 8 - GetTextSize ( display ) . y / 2 } , display , Pixel ( 255 , 255 , 255 , numb . alpha ) , { 2 , 2 } ) ;
DrawStringDecal ( { ( ( numb - > x - PLAYER_COORDS [ 0 ] ) * 32 + WIDTH / 2 ) - GetTextSize ( display ) . x / 2 , ( ( numb - > y - PLAYER_COORDS [ 1 ] ) * 32 + HEIGHT / 2 ) - 8 - GetTextSize ( display ) . y / 2 } , display , Pixel ( 255 , 255 , 255 , numb - > alpha ) , { 2 , 2 } ) ;
//std::cout<<numb->x<<"/"<<numb->y<<" "<<(((numb->x-PLAYER_COORDS[0])*32+WIDTH/2)-GetTextSize(display).x/2)<<","<<(((numb->y-PLAYER_COORDS[1])*32+HEIGHT/2)-8-GetTextSize(display).y/2)<<": ("<<numb->alpha<<")"<<display<<"\n";
}
}
if ( messageBoxVisible ) {
@ -1144,7 +1155,7 @@ public:
}
void DrawHealthbar ( vf2d pos , float width , float pct , Pixel col ) {
GradientFillRectDecal ( pos , { width * pct , 8 } , RED , RED , Pixel ( ( 1 / pct ) * 255 , 255 * pct , 0 , 255 ) ) ;
GradientFillRectDecal ( pos , { width * pct , 8 } , RED , RED , Pixel ( ( 1 / pct ) * 255 , 255 * pct , 0 , 255 ) , Pixel ( ( 1 / pct ) * 255 , 255 * pct , 0 , 255 ) ) ;
DrawDecal ( pos , HEALTHBAR_DECAL , { width / 32 , 1 } , col ) ;
}
@ -1363,18 +1374,19 @@ public:
void effectRadius ( vi2d coords , WEATHER_POWER * power , bool playerForce ) {
int finalDamage = power - > damage + rand ( ) % power - > damageRoll * sign ( power - > damage ) ;
std : : cout < < " Emitting effect radius for " < < power - > name < < " for PlayerForce: " < < playerForce < < " \n " ;
if ( finalDamage < 0 ) {
//This is a healing effect.
if ( playerForce ) {
PLAYER_HP = std : : clamp ( PLAYER_HP - finalDamage , 0 , PLAYER_MAXHP ) ;
DisplayNumber numb ( finalDamage , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] , frameCount ) ;
DisplayNumber * numb = new DisplayNumber ( finalDamage , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] , frameCount ) ;
BATTLE_DISPLAY_NUMBERS . push_back ( numb ) ;
} else {
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
if ( distancetoCoords ( { ent - > x , ent - > y } , coords ) < = power - > range ) {
if ( distancetoCoords ( { ( ent - > x + CURRENT_ENCOUNTER . x ) * 32 , ( ent - > y + CURRENT_ENCOUNTER . y ) * 32 } , coords * 32 ) < = power - > range ) {
ent - > hp = std : : clamp ( ent - > hp - finalDamage , 0 , ent - > maxhp ) ;
DisplayNumber numb ( finalDamage , ent - > x , ent - > y , frameCount ) ;
DisplayNumber * numb = new DisplayNumber ( finalDamage , ent - > x + CURRENT_ENCOUNTER . x , ent - > y + CURRENT_ENCOUNTER . y , frameCount ) ;
BATTLE_DISPLAY_NUMBERS . push_back ( numb ) ;
ent - > damageFrame = frameCount ;
}
@ -1385,16 +1397,17 @@ public:
if ( playerForce ) {
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
if ( distancetoCoords ( { ent - > x , ent - > y } , coords ) < = power - > range ) {
std : : cout < < " Distance was " < < distancetoCoords ( { ( ent - > x + CURRENT_ENCOUNTER . x ) * 32 , ( ent - > y + CURRENT_ENCOUNTER . y ) * 32 } , coords * 32 ) < < " \n " ;
if ( distancetoCoords ( { ( ent - > x + CURRENT_ENCOUNTER . x ) * 32 , ( ent - > y + CURRENT_ENCOUNTER . y ) * 32 } , coords * 32 ) < = power - > range ) {
ent - > hp = std : : clamp ( ent - > hp - finalDamage , 0 , ent - > maxhp ) ;
DisplayNumber numb ( finalDamage , ent - > x , ent - > y , frameCount ) ;
DisplayNumber * numb = new DisplayNumber ( finalDamage , ent - > x + CURRENT_ENCOUNTER . x , ent - > y + CURRENT_ENCOUNTER . y , frameCount ) ;
BATTLE_DISPLAY_NUMBERS . push_back ( numb ) ;
ent - > damageFrame = frameCount ;
}
}
} else {
PLAYER_HP = std : : clamp ( PLAYER_HP - finalDamage , 0 , PLAYER_MAXHP ) ;
DisplayNumber numb ( finalDamage , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] , frameCount ) ;
DisplayNumber * numb = new DisplayNumber ( finalDamage , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] , frameCount ) ;
BATTLE_DISPLAY_NUMBERS . push_back ( numb ) ;
}
}
@ -1415,6 +1428,5 @@ int main()
SeasonsOfLoneliness demo ;
if ( demo . Construct ( 256 , 224 , 4 , 4 ) )
demo . Start ( ) ;
return 0 ;
}