@ -201,18 +201,21 @@ namespace effect {
class Pixel {
public :
vf2d pos , size , spd ;
olc : : Pixel col ;
int r , g , b , a ;
int o_r , o_g , o_b , o_a ;
Pixel ( ) {
pos = { 0 , 0 } ;
size = { 0 , 0 } ;
spd = { 0 , 0 } ;
col = BLANK ;
} ;
Pixel ( vf2d pos , vf2d size , vf2d spd , olc : : Pixel col ) {
this - > pos = pos ;
this - > size = size ;
this - > spd = spd ;
this - > col = col ;
this - > r = this - > o_r = col . r ;
this - > g = this - > o_g = col . g ;
this - > b = this - > o_b = col . b ;
this - > a = this - > o_a = col . a ;
}
} ;
} ;
@ -282,15 +285,15 @@ public:
Animation POWER_SNOWSTORM_ANIMATION ;
Animation CONSUME_SNACK_ANIMATION ;
Animation CONSUME_MEAL_ANIMATION ;
ParticleEffect * HAILSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 4 , 4 } , { - 0. 2, 0.0 5 } , { - 0.05 , 0. 2 } , Pixel ( 143 , 242 , 255 , 255 ) , Pixel ( 255 , 255 , 255 , 255 ) , 300 , Pixel ( 220 , 226 , 227 , 64 ) ) ;
ParticleEffect * HURRICANE_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 2 , 2 } , { - 0.4 , 0. 1} , { - 0.1 , 0. 4} , Pixel ( 225 , 248 , 252 , 64 ) , Pixel ( 255 , 255 , 255 , 128 ) , 300 , Pixel ( 220 , 226 , 227 , 128 ) ) ;
ParticleEffect * METEOR_RAIN_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 3 , 3 } , { 6 , 6 } , { - 0. 1, 0.0 2 } , { - 0.02 , 0. 1 } , Pixel ( 46 , 31 , 31 , 255 ) , Pixel ( 43 , 31 , 46 , 255 ) , 50 , Pixel ( 30 , 10 , 36 , 96 ) ) ;
ParticleEffect * METEOR_STORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 3 , 3 } , { 10 , 10 } , { - 0. 2, 0.0 1 } , { - 0.01 , 0. 2 } , Pixel ( 46 , 31 , 31 , 255 ) , Pixel ( 181 , 72 , 46 , 255 ) , 75 , Pixel ( 30 , 10 , 36 , 96 ) ) ;
ParticleEffect * SNOWSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 3 , 3 } , { - 0. 1, 0.0 5 } , { 0.1 , 0. 2} , Pixel ( 193 , 198 , 201 , 200 ) , Pixel ( 255 , 255 , 255 , 255 ) , 400 , Pixel ( 220 , 226 , 227 , 128 ) ) ;
ParticleEffect * SANDSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 3 , 3 } , { - 0.2 , 0.1 } , { 0.2 , 0. 3} , Pixel ( 133 , 98 , 66 , 130 ) , Pixel ( 158 , 93 , 33 , 210 ) , 300 , Pixel ( 87 , 78 , 69 , 64 ) ) ;
ParticleEffect * SEED_STORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 2 , 2 } , { - 0.0 5 , - 0. 1} , { 0.0 5 , - 0.0 2 } , Pixel ( 65 , 98 , 66 , 130 ) , Pixel ( 65 , 117 , 60 , 210 ) , 100 , Pixel ( 70 , 158 , 62 , 64 ) ) ;
ParticleEffect * AVALANCHE_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 8 , 8 } , { - 0.4 , 0.2 } , { 0.4 , 0. 4} , Pixel ( 143 , 242 , 255 , 255 ) , Pixel ( 255 , 255 , 255 , 255 ) , 300 , Pixel ( 220 , 226 , 227 , 64 ) ) ;
ParticleEffect * CONSUME_SNACK_EFF = new ParticleEffect ( { 0 , 0 } , { 64 , 64 } , { 64 , 64 } , { 64 , 64 } , { 1 , 1 } , { 2 , 2 } , { - 0.0 1 , - 0.0 5 } , { 0.0 1 , - 0.0 05 } , Pixel ( 255 , 255 , 255 , 130 ) , Pixel ( 255 , 255 , 255 , 210 ) , 30 , Pixel ( 147 , 161 , 90 , 64 ) ) ; //Used for CONSUME_MEAL too.
ParticleEffect * HAILSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 4 , 4 } , { - 2 , 0.5 } , { - 0.5 , 2 } , Pixel ( 143 , 242 , 255 , 255 ) , Pixel ( 255 , 255 , 255 , 255 ) , 300 , Pixel ( 220 , 226 , 227 , 0 ) ) ;
ParticleEffect * HURRICANE_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 2 , 2 } , { - 4 , 1 } , { - 1 , 4 } , Pixel ( 225 , 248 , 252 , 64 ) , Pixel ( 255 , 255 , 255 , 128 ) , 300 , Pixel ( 220 , 226 , 227 , 0 ) ) ;
ParticleEffect * METEOR_RAIN_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 3 , 3 } , { 6 , 6 } , { - 1 , 0.2 } , { - 0.2 , 1 } , Pixel ( 46 , 31 , 31 , 255 ) , Pixel ( 43 , 31 , 46 , 255 ) , 50 , Pixel ( 30 , 10 , 36 , 0 ) ) ;
ParticleEffect * METEOR_STORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 3 , 3 } , { 10 , 10 } , { - 2 , 0.1 } , { - 0.1 , 2 } , Pixel ( 46 , 31 , 31 , 255 ) , Pixel ( 181 , 72 , 46 , 255 ) , 75 , Pixel ( 30 , 10 , 36 , 48 ) ) ;
ParticleEffect * SNOWSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 3 , 3 } , { - 1 , 0.5 } , { 1 , 2 } , Pixel ( 193 , 198 , 201 , 200 ) , Pixel ( 255 , 255 , 255 , 255 ) , 400 , Pixel ( 220 , 226 , 227 , 0 ) ) ;
ParticleEffect * SANDSTORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 3 , 3 } , { - 20 , 1 } , { 20 , 3 } , Pixel ( 133 , 98 , 66 , 130 ) , Pixel ( 158 , 93 , 33 , 210 ) , 300 , Pixel ( 87 , 78 , 69 , 0 ) ) ;
ParticleEffect * SEED_STORM_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 2 , 2 } , { - 0.5 , - 1 } , { 0.5 , - 0.2 } , Pixel ( 65 , 98 , 66 , 130 ) , Pixel ( 65 , 117 , 60 , 210 ) , 100 , Pixel ( 70 , 158 , 62 , 0 ) ) ;
ParticleEffect * AVALANCHE_EFF = new ParticleEffect ( { 0 , 0 } , { WIDTH , HEIGHT } , { 0 , 0 } , { WIDTH , HEIGHT } , { 1 , 1 } , { 8 , 8 } , { - 4 , 2 } , { 4 , 4 } , Pixel ( 143 , 242 , 255 , 255 ) , Pixel ( 255 , 255 , 255 , 255 ) , 300 , Pixel ( 220 , 226 , 227 , 0 ) ) ;
ParticleEffect * CONSUME_SNACK_EFF = new ParticleEffect ( { 0 , 0 } , { 64 , 64 } , { 64 , 64 } , { 64 , 64 } , { 1 , 1 } , { 2 , 2 } , { - 0.1 , - 0.5 } , { 0.1 , - 0.05 } , Pixel ( 255 , 255 , 255 , 130 ) , Pixel ( 255 , 255 , 255 , 210 ) , 30 , Pixel ( 147 , 161 , 90 , 0 ) ) ; //Used for CONSUME_MEAL too.
WEATHER_POWER * HAILSTORM = new WEATHER_POWER ( " Hailstorm " , " Causes a flurry of hard cold rocks to be unleashed in target area. 60+30d " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 60 , 30 , 160 , Pixel ( 72 , 160 , 212 , 255 ) , Pixel ( 93 , 161 , 163 , 255 ) , 120 , HAILSTORM_EFF ) ;
WEATHER_POWER * HURRICANE = new WEATHER_POWER ( " Hurricane " , " Causes heavy winds, scattering seeds, heavy rain. 20+10d " , & POWER_HURRICANE_ANIMATION , & POWER_HURRICANE_ANIMATION , 20 , 10 , 200 , Pixel ( 99 , 148 , 132 , 255 ) , Pixel ( 121 , 132 , 140 , 255 ) , 120 , HURRICANE_EFF ) ;
WEATHER_POWER * METEOR_RAIN = new WEATHER_POWER ( " Meteor Rain " , " Causes space rocks to fall on target area. 50+50d " , & POWER_METEOR_SHOWER_ANIMATION , & POWER_METEOR_SHOWER_ANIMATION , 50 , 50 , 96 , Pixel ( 96 , 86 , 153 , 255 ) , Pixel ( 170 , 103 , 201 , 255 ) , 120 , METEOR_STORM_EFF ) ;
@ -327,11 +330,13 @@ public:
bool PLAYER_TURN_COMPLETE = false ;
int FOOD_REGEN_TURNS = 0 ;
WEATHER_POWER * CUTSCENE_DISPLAYED_CARD ;
Pixel FOREGROUD_EFFECT_COLOR ;
Pixel FOREGROUND_EFFECT_COLOR ;
Pixel ORIGINAL_FOREGROUND_EFFECT_COLOR ;
int PIXEL_LIMIT = 0 ;
vf2d PIXEL_POS ;
vf2d PIXEL_SIZE ;
std : : vector < WEATHER_POWER * > MOVESET_SPIDEY ;
float PIXEL_EFFECT_TRANSPARENCY = 0.5 ;
Decal * DOME_DECAL , * FOOD_METER_DECAL , * OXYGEN_METER_DECAL , * PLANT_DECAL ,
@ -346,7 +351,7 @@ public:
std : : queue < int > turnOrder ;
# define MAX_PIXELS 500
effect : : Pixel pixels [ MAX_PIXELS ] ;
effect : : Pixel * pixels [ MAX_PIXELS ] ;
bool OnUserCreate ( ) override
{
@ -354,7 +359,7 @@ public:
ConsoleCaptureStdOut ( true ) ;
# define LAYERS 2 //How many layers exist.
for ( int i = 0 ; i < LAYERS - 1 ; i + + ) {
for ( int i = 1 ; i < LAYERS ; i + + ) {
CreateLayer ( ) ;
EnableLayer ( i , true ) ;
}
@ -479,6 +484,12 @@ public:
BASE_OBJECTS [ " METEORSHOWER_NODE " ] = new ObjectLoadInfo ( POWER_METEOR_SHOWER_DECAL , & POWER_METEOR_SHOWER_ANIMATION ) ;
BASE_OBJECTS [ " METEORSTORM_NODE " ] = new ObjectLoadInfo ( POWER_METEOR_STORM_DECAL , & POWER_METEOR_STORM_ANIMATION ) ;
BASE_OBJECTS [ " SNOWSTORM_NODE " ] = new ObjectLoadInfo ( POWER_SNOWSTORM_DECAL , & POWER_SNOWSTORM_ANIMATION ) ;
for ( int i = 0 ; i < MAX_PIXELS ; i + + ) {
pixels [ i ] = new effect : : Pixel ( ) ;
}
LoadMap ( STARTING_MAP ) ;
return true ;
}
@ -888,6 +899,22 @@ public:
}
} break ;
case battle : : WAIT_TURN_ANIMATION : {
if ( EFFECT_TIMER = = 0 ) {
PIXEL_EFFECT_TRANSPARENCY = 0 ;
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
if ( PLAYER_SELECTED_TARGET = = - 2 ) {
applyPixelEffect ( BATTLE_CARD_SELECTION , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] ) ;
} else {
applyPixelEffect ( BATTLE_CARD_SELECTION , CURRENT_ENCOUNTER . x + CURRENT_ENCOUNTER . entities [ PLAYER_SELECTED_TARGET ] - > x , CURRENT_ENCOUNTER . y + CURRENT_ENCOUNTER . entities [ PLAYER_SELECTED_TARGET ] - > y ) ;
}
} else {
if ( CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > selectedMove - > damage < 0 ) {
applyPixelEffect ( CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > selectedMove , CURRENT_ENCOUNTER . x + CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > x , CURRENT_ENCOUNTER . y + CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > y ) ;
} else {
applyPixelEffect ( CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > selectedMove , PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] ) ;
}
}
}
EFFECT_TIMER + + ;
WEATHER_POWER * ref ;
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
@ -895,6 +922,7 @@ public:
} else {
ref = CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] - > selectedMove ;
}
PIXEL_EFFECT_TRANSPARENCY = ( 0.5 * cos ( ( ( M_PI / ( 30.0 * ( ref - > effectTime / 120.0 ) ) ) / 2 ) * EFFECT_TIMER - M_PI ) + 0.5 ) ;
if ( EFFECT_TIMER = = 30 & & ref - > name . compare ( " Seed Storm " ) = = 0 ) {
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
effectRadius ( { PLAYER_COORDS [ 0 ] , PLAYER_COORDS [ 1 ] } , ref , true ) ;
@ -920,19 +948,20 @@ public:
}
}
for ( int i = 0 ; i < PIXEL_LIMIT ; i + + ) {
pixels [ i ] . pos + = pixels [ i ] . spd ;
if ( pixels [ i ] . pos . x < PIXEL_POS . x ) {
pixels [ i ] . pos . x = PIXEL_POS . x + PIXEL_SIZE . x ;
pixels [ i ] - > pos + = pixels [ i ] - > spd ;
if ( pixels [ i ] - > pos . x < PIXEL_POS . x ) {
pixels [ i ] - > pos . x = PIXEL_POS . x + PIXEL_SIZE . x ;
}
if ( pixels [ i ] . pos . x > PIXEL_POS . x + PIXEL_SIZE . x ) {
pixels [ i ] . pos . x = PIXEL_POS . x ;
if ( pixels [ i ] - > pos . x > PIXEL_POS . x + PIXEL_SIZE . x ) {
pixels [ i ] - > pos . x = PIXEL_POS . x ;
}
if ( pixels [ i ] . pos . y < PIXEL_POS . y ) {
pixels [ i ] . pos . y = PIXEL_POS . y + PIXEL_SIZE . y ;
if ( pixels [ i ] - > pos . y < PIXEL_POS . y ) {
pixels [ i ] - > pos . y = PIXEL_POS . y + PIXEL_SIZE . y ;
}
if ( pixels [ i ] . pos . y > PIXEL_POS . y + PIXEL_SIZE . y ) {
pixels [ i ] . pos . y = PIXEL_POS . y ;
if ( pixels [ i ] - > pos . y > PIXEL_POS . y + PIXEL_SIZE . y ) {
pixels [ i ] - > pos . y = PIXEL_POS . y ;
}
pixels [ i ] - > a = pixels [ i ] - > o_a * PIXEL_EFFECT_TRANSPARENCY ;
}
if ( EFFECT_TIMER > ref - > effectTime ) {
BATTLE_STATE = battle : : DAMAGE_RESOLUTION ;
@ -980,6 +1009,7 @@ public:
}
}
BATTLE_STATE = battle : : WAIT_TURN_ANIMATION ;
PIXEL_EFFECT_TRANSPARENCY = 0 ;
EFFECT_TIMER = 0 ;
}
}
@ -1175,14 +1205,14 @@ public:
}
SetDrawTarget ( nullptr ) ;
for ( int i = 0 ; i < PIXEL_LIMIT ; i + + ) {
if ( pixels [ i ] . size . x = = 1 & & pixels [ i ] . size . y = = 1 ) {
Draw ( pixels [ i ] . pos , pixels [ i ] . col ) ;
if ( pixels [ i ] - > size . x = = 1 & & pixels [ i ] - > size . y = = 1 ) {
Draw ( pixels [ i ] - > pos , { pixels [ i ] - > r , pixels [ i ] - > g , pixels [ i ] - > b , pixels [ i ] - > a } ) ;
} else {
FillRectDecal ( pixels [ i ] . pos , pixels [ i ] . size , pixels [ i ] . col ) ;
FillRectDecal ( pixels [ i ] - > pos , pixels [ i ] - > size , { pixels [ i ] - > r , pixels [ i ] - > g , pixels [ i ] - > b , pixels [ i ] - > a } ) ;
}
}
SetDrawTarget ( 1 ) ;
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( 0 , 0 , 0 , transparency ) ) ;
FillRectDecal ( { 0 , 0 } , { WIDTH , HEIGHT } , Pixel ( ORIGINAL_FOREGROUND_EFFECT_COLOR . r , ORIGINAL_FOREGROUND_EFFECT_COLOR . g , ORIGINAL_FOREGROUND_EFFECT_COLOR . b , ORIGINAL_FOREGROUND_EFFECT_COLOR . a * PIXEL_EFFECT_TRANSPARENCY ) ) ;
} break ;
}
if ( IN_BATTLE_ENCOUNTER | | ( ! CUTSCENE_ACTIVE & & PLAYER_HP ! = PLAYER_MAXHP ) ) {
@ -1650,14 +1680,39 @@ public:
CUTSCENE_DISPLAYED_CARD = POWER ;
}
void applyPixelEffect ( WEATHER_POWER * power , int x , int y ) {
SetDrawTarget ( nullptr ) ;
Clear ( BLANK ) ;
SetDrawTarget ( 1 ) ;
applyPixelEffect (
{ ( x - PLAYER_COORDS [ 0 ] ) * 32 + WIDTH / 2 - 16 - power - > effect - > effectSize . x / 2 , ( y - PLAYER_COORDS [ 1 ] ) * 32 + HEIGHT / 2 - 16 - power - > effect - > effectSize . y / 2 } ,
power - > effect - > effectSize ,
power - > effect - > pos_low ,
power - > effect - > pos_high ,
power - > effect - > size_low ,
power - > effect - > size_high ,
power - > effect - > spd_low ,
power - > effect - > spd_high ,
power - > effect - > col_low ,
power - > effect - > col_high ,
power - > effect - > amt ,
power - > effect - > foregroundColor
) ;
}
void applyPixelEffect ( vf2d effectPos , vf2d effectSize , vf2d pos_low , vf2d pos_high , vf2d size_low , vf2d size_high , vf2d spd_low , vf2d spd_high , olc : : Pixel col_low , olc : : Pixel col_high , int amt , olc : : Pixel foregroundColor ) {
for ( int i = 0 ; i < amt ; i + + ) {
pixels [ i ] . pos = { range ( pos_low . x , pos_high . x ) , range ( pos_low . y , pos_high . y ) } ;
pixels [ i ] . size = { range ( size_low . x , size_high . x ) , range ( size_low . y , size_high . y ) } ;
pixels [ i ] . spd = { range ( spd_low . x , spd_high . x ) , range ( spd_low . y , spd_high . y ) } ;
pixels [ i ] . col = Pixel ( range ( col_low . r , col_high . r ) , range ( col_low . g , col_high . g ) , range ( col_low . b , col_high . b ) , range ( col_low . a , col_high . a ) ) ;
pixels [ i ] - > pos = { range ( pos_low . x , pos_high . x ) , range ( pos_low . y , pos_high . y ) } ;
pixels [ i ] - > size = { range ( size_low . x , size_high . x ) , range ( size_low . y , size_high . y ) } ;
std : : cout < < std : : to_string ( pixels [ i ] - > size . x ) < < " , " < < std : : to_string ( pixels [ i ] - > size . y ) < < " \n " ;
pixels [ i ] - > spd = { range ( spd_low . x , spd_high . x ) , range ( spd_low . y , spd_high . y ) } ;
pixels [ i ] - > r = range ( col_low . r , col_high . r ) ;
pixels [ i ] - > g = range ( col_low . g , col_high . g ) ;
pixels [ i ] - > b = range ( col_low . b , col_high . b ) ;
pixels [ i ] - > a = range ( col_low . a , col_high . a ) ;
pixels [ i ] - > o_a = range ( col_low . a , col_high . a ) ;
}
FOREGROUD_EFFECT_COLOR = foregroundColor ;
ORIGINAL_ FOREGROUND_EFFECT_COLOR = FOREGROUN D_EFFECT_COLOR= foregroundColor ;
PIXEL_POS = effectPos ;
PIXEL_SIZE = effectSize ;
PIXEL_LIMIT = amt ;
@ -1669,7 +1724,7 @@ public:
//Returns a number between 0.0 and X.
float random ( float X ) {
float r2 = static_cast < float > ( rand ( ) ) / ( static_cast < float > ( RAND_MAX / X ) ) ;
return ( float ) rand ( ) / RAND_MAX * X ;
}
float range ( float val1 , float val2 ) {