@ -3,6 +3,7 @@
# include "data.h"
# include "data.h"
# define OLC_PGEX_SPLASHSCREEN
# define OLC_PGEX_SPLASHSCREEN
# include "splash.h"
# include "splash.h"
# include <stack>
using namespace olc ;
using namespace olc ;
@ -12,6 +13,7 @@ enum GAMESTATE{
CUTSCENE_3 ,
CUTSCENE_3 ,
GAMEWORLD ,
GAMEWORLD ,
WAITING_FOR_CUTSCENE_3 ,
WAITING_FOR_CUTSCENE_3 ,
GAME_OVER ,
} ;
} ;
namespace cutscene {
namespace cutscene {
@ -33,7 +35,8 @@ namespace battle{
ENEMY_SELECTION ,
ENEMY_SELECTION ,
MOVE_RESOLUTION ,
MOVE_RESOLUTION ,
PERFORM_TURN ,
PERFORM_TURN ,
WAIT_TURN_ANIMATION
WAIT_TURN_ANIMATION ,
DAMAGE_RESOLUTION ,
} ;
} ;
}
}
@ -100,7 +103,8 @@ class WEATHER_POWER{
int playerOwnCount ;
int playerOwnCount ;
Pixel bgcol ;
Pixel bgcol ;
Pixel textcol ;
Pixel textcol ;
WEATHER_POWER ( std : : string name , std : : string desc , Animation * icon , Animation * effect , int dmg , int dmgRoll , int range , Pixel bgcol , Pixel textcol ) {
int effectTime ;
WEATHER_POWER ( std : : string name , std : : string desc , Animation * icon , Animation * effect , int dmg , int dmgRoll , int range , Pixel bgcol , Pixel textcol , int effectTime ) {
this - > description = desc ;
this - > description = desc ;
this - > name = name ;
this - > name = name ;
this - > anim = icon ;
this - > anim = icon ;
@ -209,14 +213,14 @@ public:
Animation POWER_METEOR_STORM_ANIMATION ;
Animation POWER_METEOR_STORM_ANIMATION ;
Animation POWER_SNOWSTORM_ANIMATION ;
Animation POWER_SNOWSTORM_ANIMATION ;
std : : vector < Entity > entityList ;
std : : vector < Entity > entityList ;
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 ) ) ;
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 ) ;
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 ) ) ;
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 ) ;
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 ) ) ;
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 ) ;
WEATHER_POWER * METEOR_STORM = new WEATHER_POWER ( " Meteor Storm " , " Larger space rocks. 120+60d " , & POWER_METEOR_STORM_ANIMATION , & POWER_METEOR_STORM_ANIMATION , 120 , 60 , 140 , Pixel ( 89 , 4 , 33 , 255 ) , Pixel ( 130 , 56 , 1 , 255 ) ) ;
WEATHER_POWER * METEOR_STORM = new WEATHER_POWER ( " Meteor Storm " , " Larger space rocks. 120+60d " , & POWER_METEOR_STORM_ANIMATION , & POWER_METEOR_STORM_ANIMATION , 120 , 60 , 140 , Pixel ( 89 , 4 , 33 , 255 ) , Pixel ( 130 , 56 , 1 , 255 ) , 120 ) ;
WEATHER_POWER * SNOWSTORM = new WEATHER_POWER ( " Snowstorm " , " Slows down targets and causes rapid temperature drops. 15+10d " , & POWER_SNOWSTORM_ANIMATION , & POWER_SNOWSTORM_ANIMATION , 15 , 10 , 140 , Pixel ( 183 , 196 , 194 , 255 ) , Pixel ( 222 , 255 , 254 , 255 ) ) ;
WEATHER_POWER * SNOWSTORM = new WEATHER_POWER ( " Snowstorm " , " Slows down targets and causes rapid temperature drops. 15+10d " , & POWER_SNOWSTORM_ANIMATION , & POWER_SNOWSTORM_ANIMATION , 15 , 10 , 140 , Pixel ( 183 , 196 , 194 , 255 ) , Pixel ( 222 , 255 , 254 , 255 ) , 120 ) ;
WEATHER_POWER * SANDSTORM = new WEATHER_POWER ( " Sandstorm " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 5 , 10 , 64 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) ) ;
WEATHER_POWER * SANDSTORM = new WEATHER_POWER ( " Sandstorm " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 5 , 10 , 64 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) , 120 ) ;
WEATHER_POWER * SEED_STORM = new WEATHER_POWER ( " Seed Storm " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 8 , 20 , 164 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) ) ;
WEATHER_POWER * SEED_STORM = new WEATHER_POWER ( " Seed Storm " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 8 , 20 , 164 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) , 120 ) ;
WEATHER_POWER * AVALANCHE = new WEATHER_POWER ( " Avalanche " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 15 , 10 , 200 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) ) ;
WEATHER_POWER * AVALANCHE = new WEATHER_POWER ( " Avalanche " , " " , & POWER_HAILSTORM_ANIMATION , & POWER_HAILSTORM_ANIMATION , 15 , 10 , 200 , Pixel ( 93 , 161 , 163 , 255 ) , Pixel ( 72 , 160 , 212 , 255 ) , 120 ) ;
bool IN_BATTLE_ENCOUNTER = false ;
bool IN_BATTLE_ENCOUNTER = false ;
int BATTLE_ENTRY_TIMER = 0 ;
int BATTLE_ENTRY_TIMER = 0 ;
int EFFECT_TIMER = 0 ;
int EFFECT_TIMER = 0 ;
@ -234,6 +238,8 @@ public:
int PLAYER_SELECTED_TARGET = - 1 ;
int PLAYER_SELECTED_TARGET = - 1 ;
int PLAYER_MAXHP = 60 ;
int PLAYER_MAXHP = 60 ;
int PLAYER_HP = PLAYER_MAXHP ;
int PLAYER_HP = PLAYER_MAXHP ;
int BATTLE_CURRENT_TURN_ENTITY = - 1 ;
int CURRENT_ENCOUNTER_IND = - 1 ;
std : : vector < WEATHER_POWER * > MOVESET_SPIDEY ;
std : : vector < WEATHER_POWER * > MOVESET_SPIDEY ;
@ -246,7 +252,7 @@ public:
std : : vector < Encounter > ENCOUNTERS ;
std : : vector < Encounter > ENCOUNTERS ;
Encounter ENCOUNTER_SPIDEY_1 ;
Encounter ENCOUNTER_SPIDEY_1 ;
Encounter CURRENT_ENCOUNTER ;
Encounter CURRENT_ENCOUNTER ;
std : : vector < int > turnOrder ;
std : : stack < int > turnOrder ;
bool OnUserCreate ( ) override
bool OnUserCreate ( ) override
{
{
@ -413,6 +419,8 @@ public:
}
}
} break ;
} break ;
case battle : : PLAYER_TARGET_SELECTION : {
case battle : : PLAYER_TARGET_SELECTION : {
//Remove the card from inventory.
BATTLE_CARD_SELECTION - > playerOwnCount - - ;
BATTLE_STATE = battle : : ENEMY_SELECTION ;
BATTLE_STATE = battle : : ENEMY_SELECTION ;
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
if ( CURRENT_ENCOUNTER . entities [ i ] . hp > 0 ) {
if ( CURRENT_ENCOUNTER . entities [ i ] . hp > 0 ) {
@ -423,13 +431,13 @@ public:
BATTLE_STATE = battle : : MOVE_RESOLUTION ;
BATTLE_STATE = battle : : MOVE_RESOLUTION ;
//Seed Storm has prio.
//Seed Storm has prio.
if ( BATTLE_CARD_SELECTION_IND ! = - 1 & & BATTLE_CARD_SELECTION - > name . compare ( " Seed Storm " ) = = 0 ) {
if ( BATTLE_CARD_SELECTION_IND ! = - 1 & & BATTLE_CARD_SELECTION - > name . compare ( " Seed Storm " ) = = 0 ) {
turnOrder . push_back ( - 1 ) ;
turnOrder . push ( - 1 ) ;
BATTLE_CARD_SELECTION_IND = - 1 ;
BATTLE_CARD_SELECTION_IND = - 1 ;
}
}
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
if ( CURRENT_ENCOUNTER . entities [ i ] . hp > 0 & & ! CURRENT_ENCOUNTER . entities [ i ] . turnComplete & &
if ( CURRENT_ENCOUNTER . entities [ i ] . hp > 0 & & ! CURRENT_ENCOUNTER . entities [ i ] . turnComplete & &
CURRENT_ENCOUNTER . entities [ i ] . selectedMove - > name . compare ( " Seed Storm " ) = = 0 ) {
CURRENT_ENCOUNTER . entities [ i ] . selectedMove - > name . compare ( " Seed Storm " ) = = 0 ) {
turnOrder . push_back ( i ) ;
turnOrder . push ( i ) ;
CURRENT_ENCOUNTER . entities [ i ] . turnComplete = true ;
CURRENT_ENCOUNTER . entities [ i ] . turnComplete = true ;
}
}
}
}
@ -438,27 +446,27 @@ public:
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
if ( ent - > hp > 0 & & ! ent - > turnComplete & &
if ( ent - > hp > 0 & & ! ent - > turnComplete & &
! ent - > slowed & & rand ( ) % 2 = = 0 ) {
! ent - > slowed & & rand ( ) % 2 = = 0 ) {
turnOrder . push_back ( i ) ;
turnOrder . push ( i ) ;
ent - > turnComplete = true ;
ent - > turnComplete = true ;
}
}
}
}
if ( BATTLE_CARD_SELECTION_IND ! = - 1 ) {
if ( BATTLE_CARD_SELECTION_IND ! = - 1 ) {
turnOrder . push_back ( - 1 ) ;
turnOrder . push ( - 1 ) ;
BATTLE_CARD_SELECTION_IND = - 1 ;
BATTLE_CARD_SELECTION_IND = - 1 ;
}
}
//Finally, any enemies that haven't gone will now go.
//Finally, any enemies that haven't gone will now go.
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
for ( int i = 0 ; i < CURRENT_ENCOUNTER . entities . size ( ) ; i + + ) {
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
Entity * ent = & CURRENT_ENCOUNTER . entities [ i ] ;
if ( ent - > hp > 0 & & ! ent - > turnComplete ) {
if ( ent - > hp > 0 & & ! ent - > turnComplete ) {
turnOrder . push_back ( i ) ;
turnOrder . push ( i ) ;
ent - > turnComplete = true ;
ent - > turnComplete = true ;
}
}
}
}
std : : cout < < " Turn order: " ;
for ( auto & order : turnOrder ) {
std : : cout < < order < < " , " ;
}
BATTLE_STATE = battle : : PERFORM_TURN ;
BATTLE_STATE = battle : : PERFORM_TURN ;
BATTLE_CURRENT_TURN_ENTITY = turnOrder . top ( ) ;
turnOrder . pop ( ) ;
BATTLE_STATE = battle : : WAIT_TURN_ANIMATION ;
EFFECT_TIMER = 0 ;
} break ;
} break ;
}
}
}
}
@ -718,6 +726,7 @@ public:
availablePowers . erase ( availablePowers . begin ( ) , availablePowers . end ( ) ) ;
availablePowers . erase ( availablePowers . begin ( ) , availablePowers . end ( ) ) ;
IN_BATTLE_ENCOUNTER = true ;
IN_BATTLE_ENCOUNTER = true ;
CURRENT_ENCOUNTER = enc ;
CURRENT_ENCOUNTER = enc ;
CURRENT_ENCOUNTER_IND = i ;
BATTLE_ENTRY_TIMER = 0 ;
BATTLE_ENTRY_TIMER = 0 ;
BATTLE_STATE = battle : : WAITING_FOR_CAMERA ;
BATTLE_STATE = battle : : WAITING_FOR_CAMERA ;
for ( int i = 0 ; i < WEATHER_POWER_COUNT ; i + + ) {
for ( int i = 0 ; i < WEATHER_POWER_COUNT ; i + + ) {
@ -772,6 +781,55 @@ public:
}
}
}
}
} break ;
} break ;
case battle : : WAIT_TURN_ANIMATION : {
EFFECT_TIMER + + ;
WEATHER_POWER * ref ;
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
ref = BATTLE_CARD_SELECTION ;
} else {
ref = CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . selectedMove ;
}
if ( EFFECT_TIMER > ref - > effectTime ) {
BATTLE_STATE = battle : : DAMAGE_RESOLUTION ;
EFFECT_TIMER = 0 ;
}
} break ;
case battle : : DAMAGE_RESOLUTION : {
EFFECT_TIMER + + ;
if ( EFFECT_TIMER > 60 ) {
if ( turnOrder . empty ( ) ) {
bool allDead = true ;
for ( auto & ent : CURRENT_ENCOUNTER . entities ) {
if ( ent . hp > 0 ) {
allDead = false ;
break ;
}
}
if ( allDead ) {
IN_BATTLE_ENCOUNTER = false ;
ENCOUNTERS . erase ( ENCOUNTERS . begin ( ) + CURRENT_ENCOUNTER_IND ) ;
BATTLE_CARD_SELECTION_IND = 0 ;
PLAYER_SELECTED_TARGET = - 1 ;
BATTLE_STATE = battle : : NONE ;
}
} else {
BATTLE_CURRENT_TURN_ENTITY = turnOrder . top ( ) ;
turnOrder . pop ( ) ;
if ( BATTLE_CURRENT_TURN_ENTITY = = - 1 ) {
if ( PLAYER_HP < = 0 ) {
GAME_STATE = GAME_OVER ;
break ;
}
} else {
if ( CURRENT_ENCOUNTER . entities [ BATTLE_CURRENT_TURN_ENTITY ] . hp < = 0 ) {
break ;
}
}
BATTLE_STATE = battle : : WAIT_TURN_ANIMATION ;
EFFECT_TIMER = 0 ;
}
}
} break ;
}
}
}
}
@ -956,7 +1014,7 @@ public:
}
}
} break ;
} break ;
}
}
if ( IN_BATTLE_ENCOUNTER ) {
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 + 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 ) ) ;
DrawStringDecal ( { 4 , HEIGHT - 10 - GetTextSize ( " HP: " ) . y } , " HP: " + std : : to_string ( PLAYER_HP ) ) ;
DrawHealthbar ( { 2 , HEIGHT - 10 } , WIDTH / 2 , PLAYER_HP / PLAYER_MAXHP , BLACK ) ;
DrawHealthbar ( { 2 , HEIGHT - 10 } , WIDTH / 2 , PLAYER_HP / PLAYER_MAXHP , BLACK ) ;