Structured the weather powers better.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 3 years ago
parent f8c2e5b061
commit b8e0037928
  1. 168
      SeasonsOfLoneliness.cpp
  2. BIN
      Seasons_of_Loneliness

@ -22,20 +22,24 @@ enum CUTSCENE{
TRANSITION_CUTSCENE, TRANSITION_CUTSCENE,
}; };
enum WEATHER_POWER{ namespace battle{
HAILSTORM, enum BATTLESTATE{
HURRICANE, NONE,
METEOR_SHOWER, WAITING_FOR_CAMERA,
METEOR_STORM, PLAYER_SELECTION,
SNOWSTORM ENEMY_SELECTION,
}; MOVE_RESOLUTION,
PERFORM_TURN,
WAIT_TURN_ANIMATION
};
}
#define WIDTH 256 #define WIDTH 256
#define HEIGHT 224 #define HEIGHT 224
#define ALPHA_SCREEN1 128 #define ALPHA_SCREEN1 128
#define ALPHA_SCREEN2 20 #define ALPHA_SCREEN2 20
#define FADE_SPD 6 #define FADE_SPD 6
#define MOVE_SPD 0.075 #define MOVE_SPD 0.1
#define MESSAGE_SCROLL_WAIT_SPD 2 //Number of frames to wait. #define MESSAGE_SCROLL_WAIT_SPD 2 //Number of frames to wait.
#define BATTLE_CAMERA_SCROLL_SPD 0.05 //How fast to scroll over to the battle. #define BATTLE_CAMERA_SCROLL_SPD 0.05 //How fast to scroll over to the battle.
@ -90,6 +94,7 @@ class Entity{
int x; int x;
int y; int y;
std::string name; std::string name;
WEATHER_POWER*selectedMove;
Entity(olc::Decal*spr,std::string name,int x,int y,int hp,int maxhp,bool isAlly=false) { Entity(olc::Decal*spr,std::string name,int x,int y,int hp,int maxhp,bool isAlly=false) {
this->spr=spr; this->spr=spr;
this->name=name; this->name=name;
@ -104,6 +109,37 @@ class Encounter{
public: public:
int x,y; int x,y;
std::vector<Entity> entities; std::vector<Entity> entities;
std::vector<int> turnOrder;
};
class WEATHER_POWER{
public:
std::string description;
std::string name;
Animation*anim;
Animation*effectAnim;
int damage;
int damageRoll;
int range;
int playerOwnCount;
WEATHER_POWER(std::string name,std::string desc,Animation*icon,Animation*effect,int dmg,int dmgRoll,int range) {
this->description=desc;
this->name=name;
this->anim=icon;
this->effectAnim=effect;
this->damage=dmg;
this->damageRoll=dmgRoll;
this->range=range;
}
WEATHER_POWER(std::string name,std::string desc,Animation*icon,Animation*effect,int dmg,int dmgRoll,int range) {
this->description=desc;
this->name=name;
this->anim=icon;
this->effectAnim=effect;
this->damage=dmg;
this->damageRoll=dmgRoll;
this->range=range;
}
}; };
class SeasonsOfLoneliness : public olc::PixelGameEngine class SeasonsOfLoneliness : public olc::PixelGameEngine
@ -170,14 +206,24 @@ 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);
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);
WEATHER_POWER*METEOR_SHOWER = new WEATHER_POWER("Meteor Shower","Causes space rocks to fall on target area. 50+50d",&POWER_METEOR_SHOWER_ANIMATION,&POWER_METEOR_SHOWER_ANIMATION,50,50,96);
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);
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);
WEATHER_POWER*SANDSTORM = new WEATHER_POWER("Sandstorm","",&POWER_HAILSTORM_ANIMATION,&POWER_HAILSTORM_ANIMATION,5,10,64);
WEATHER_POWER*PETAL_BLOSSOM = new WEATHER_POWER("Petal Blossom","",&POWER_HAILSTORM_ANIMATION,&POWER_HAILSTORM_ANIMATION,8,20,164);
WEATHER_POWER*AVALANCHE = new WEATHER_POWER("Avalanche","",&POWER_HAILSTORM_ANIMATION,&POWER_HAILSTORM_ANIMATION,15,10,200);
bool IN_BATTLE_ENCOUNTER = false; bool IN_BATTLE_ENCOUNTER = false;
int BATTLE_ENTRY_TIMER = 0; int BATTLE_ENTRY_TIMER = 0;
int WEATHER_POWERS[15] = { int EFFECT_TIMER = 0;
3, #define WEATHER_POWER_COUNT 15 //Number of powers that are in the game. Update storage array accordingly.
1, WEATHER_POWER*WEATHER_POWERS[WEATHER_POWER_COUNT] = {
5, HAILSTORM,
0, HURRICANE,
0, METEOR_SHOWER,
METEOR_STORM,
SNOWSTORM,
0, 0,
0, 0,
0, 0,
@ -186,6 +232,9 @@ public:
0, 0,
0, 0,
0,0,0}; 0,0,0};
battle::BATTLESTATE BATTLE_STATE=battle::NONE;
std::vector<WEATHER_POWER*> availablePowers;
WEATHER_POWER*BATTLE_CARD_SELECTION=HAILSTORM;
olc::Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL,*PLANT_DECAL, olc::Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL,*PLANT_DECAL,
@ -283,6 +332,10 @@ public:
POWER_SNOWSTORM_ANIMATION.frames.push_back({64,0}); POWER_SNOWSTORM_ANIMATION.frames.push_back({64,0});
POWER_SNOWSTORM_ANIMATION.skip_frames=nodeAnimationSkipFrames; POWER_SNOWSTORM_ANIMATION.skip_frames=nodeAnimationSkipFrames;
HAILSTORM->playerOwnCount=3;
HURRICANE->playerOwnCount=1;
METEOR_SHOWER->playerOwnCount=5;
ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",2,3,80,80,false)); ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",2,3,80,80,false));
ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",4,4,80,80,false)); ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",4,4,80,80,false));
ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",6,2,80,80,false)); ENCOUNTER_SPIDEY_1.entities.push_back(*new Entity(SPIDEY_DECAL,"Spidey",6,2,80,80,false));
@ -512,31 +565,31 @@ public:
Object obj = OBJECTS[i]; Object obj = OBJECTS[i];
if (obj.name.compare("HAILSTORM_NODE")==0&&collidesWithPlayer(obj)) { if (obj.name.compare("HAILSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2; int amountGained=rand()%4+2;
WEATHER_POWERS[HAILSTORM]+=amountGained; HAILSTORM->playerOwnCount+=amountGained;
cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n"; cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--); OBJECTS.erase(OBJECTS.begin()+i--);
} else } else
if (obj.name.compare("HURRICANE_NODE")==0&&collidesWithPlayer(obj)) { if (obj.name.compare("HURRICANE_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2; int amountGained=rand()%4+2;
WEATHER_POWERS[HURRICANE]+=amountGained; HURRICANE->playerOwnCount+=amountGained;
cout<<"Increased HURRICANE power inventory count by "<<amountGained<<".\n"; cout<<"Increased HURRICANE power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--); OBJECTS.erase(OBJECTS.begin()+i--);
} else } else
if (obj.name.compare("METEORSHOWER_NODE")==0&&collidesWithPlayer(obj)) { if (obj.name.compare("METEORSHOWER_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2; int amountGained=rand()%4+2;
WEATHER_POWERS[METEOR_SHOWER]+=amountGained; METEOR_SHOWER->playerOwnCount+=amountGained;
cout<<"Increased METEORSHOWER power inventory count by "<<amountGained<<".\n"; cout<<"Increased METEORSHOWER power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--); OBJECTS.erase(OBJECTS.begin()+i--);
} else } else
if (obj.name.compare("METEORSTORM_NODE")==0&&collidesWithPlayer(obj)) { if (obj.name.compare("METEORSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2; int amountGained=rand()%4+2;
WEATHER_POWERS[METEOR_STORM]+=amountGained; METEOR_STORM->playerOwnCount+=amountGained;
cout<<"Increased METEORSTORM power inventory count by "<<amountGained<<".\n"; cout<<"Increased METEORSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--); OBJECTS.erase(OBJECTS.begin()+i--);
} else } else
if (obj.name.compare("SNOWSTORM_NODE")==0&&collidesWithPlayer(obj)) { if (obj.name.compare("SNOWSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2; int amountGained=rand()%4+2;
WEATHER_POWERS[SNOWSTORM]+=amountGained; SNOWSTORM->playerOwnCount+=amountGained;
cout<<"Increased SNOWSTORM power inventory count by "<<amountGained<<".\n"; cout<<"Increased SNOWSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--); OBJECTS.erase(OBJECTS.begin()+i--);
} }
@ -550,44 +603,61 @@ public:
for (int i=0;i<ENCOUNTERS.size();i++) { for (int i=0;i<ENCOUNTERS.size();i++) {
Encounter enc = ENCOUNTERS[i]; Encounter enc = ENCOUNTERS[i];
if (collidesWithPlayer(enc)) { if (collidesWithPlayer(enc)) {
availablePowers.erase(availablePowers.begin(),availablePowers.end());
IN_BATTLE_ENCOUNTER=true; IN_BATTLE_ENCOUNTER=true;
CURRENT_ENCOUNTER=enc; CURRENT_ENCOUNTER=enc;
BATTLE_ENTRY_TIMER=0; BATTLE_ENTRY_TIMER=0;
BATTLE_STATE=battle::WAITING_FOR_CAMERA;
for (int i=0;i<WEATHER_POWER_COUNT;i++) {
if (WEATHER_POWERS[i]->playerOwnCount>0) {
availablePowers.push_back(WEATHER_POWERS[i]);
cout<<"There are x"<<WEATHER_POWERS[i]->playerOwnCount<<" of "<<WEATHER_POWERS[i]->name<<"\n";
}
}
BATTLE_CARD_SELECTION=availablePowers[0];
} }
} }
} }
if (IN_BATTLE_ENCOUNTER) { if (IN_BATTLE_ENCOUNTER) {
BATTLE_ENTRY_TIMER++; BATTLE_ENTRY_TIMER++;
if (BATTLE_ENTRY_TIMER>45) { switch (BATTLE_STATE) {
int TARGET_COORDS_X=CURRENT_ENCOUNTER.x+WIDTH/32/2; case battle::WAITING_FOR_CAMERA: {
int TARGET_COORDS_Y=CURRENT_ENCOUNTER.y+HEIGHT/32/2; if (BATTLE_ENTRY_TIMER>45) {
if (PLAYER_COORDS[0]!=TARGET_COORDS_X) { int TARGET_COORDS_X=CURRENT_ENCOUNTER.x+WIDTH/32/2;
if (PLAYER_COORDS[0]<TARGET_COORDS_X) { int TARGET_COORDS_Y=CURRENT_ENCOUNTER.y+HEIGHT/32/2;
PLAYER_COORDS[0]+=BATTLE_CAMERA_SCROLL_SPD; if (PLAYER_COORDS[0]==TARGET_COORDS_X&&PLAYER_COORDS[1]==TARGET_COORDS_Y) {
if (PLAYER_COORDS[0]>TARGET_COORDS_X) { BATTLE_STATE = battle::PLAYER_SELECTION;
PLAYER_COORDS[0]=TARGET_COORDS_X; EFFECT_TIMER = 0;
} } else
} else { if (PLAYER_COORDS[0]!=TARGET_COORDS_X) {
PLAYER_COORDS[0]-=BATTLE_CAMERA_SCROLL_SPD; if (PLAYER_COORDS[0]<TARGET_COORDS_X) {
if (PLAYER_COORDS[0]<TARGET_COORDS_X) { PLAYER_COORDS[0]+=BATTLE_CAMERA_SCROLL_SPD;
PLAYER_COORDS[0]=TARGET_COORDS_X; if (PLAYER_COORDS[0]>TARGET_COORDS_X) {
} PLAYER_COORDS[0]=TARGET_COORDS_X;
} }
} } else {
if (PLAYER_COORDS[1]!=TARGET_COORDS_Y) { PLAYER_COORDS[0]-=BATTLE_CAMERA_SCROLL_SPD;
if (PLAYER_COORDS[1]<TARGET_COORDS_Y) { if (PLAYER_COORDS[0]<TARGET_COORDS_X) {
PLAYER_COORDS[1]+=BATTLE_CAMERA_SCROLL_SPD; PLAYER_COORDS[0]=TARGET_COORDS_X;
if (PLAYER_COORDS[1]>TARGET_COORDS_Y) { }
PLAYER_COORDS[1]=TARGET_COORDS_Y; }
} }
} else { if (PLAYER_COORDS[1]!=TARGET_COORDS_Y) {
PLAYER_COORDS[1]-=BATTLE_CAMERA_SCROLL_SPD; if (PLAYER_COORDS[1]<TARGET_COORDS_Y) {
if (PLAYER_COORDS[1]<TARGET_COORDS_Y) { PLAYER_COORDS[1]+=BATTLE_CAMERA_SCROLL_SPD;
PLAYER_COORDS[1]=TARGET_COORDS_Y; if (PLAYER_COORDS[1]>TARGET_COORDS_Y) {
PLAYER_COORDS[1]=TARGET_COORDS_Y;
}
} else {
PLAYER_COORDS[1]-=BATTLE_CAMERA_SCROLL_SPD;
if (PLAYER_COORDS[1]<TARGET_COORDS_Y) {
PLAYER_COORDS[1]=TARGET_COORDS_Y;
}
}
} }
} }
} }break;
} }
} }
@ -756,6 +826,14 @@ public:
GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1}); GradientFillRectDecal({WIDTH/2,HEIGHT/2},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1});
}break; }break;
} }
switch (BATTLE_STATE) {
case battle::PLAYER_SELECTION:{
GradientFillRectDecal({WIDTH/6,HEIGHT/6},{WIDTH/3,HEIGHT/6*2},olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,0),olc::Pixel(72, 160, 212,255));
GradientFillRectDecal({WIDTH/6*3+1,HEIGHT/6},{WIDTH/3,HEIGHT/6*2},olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,0),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255));
GradientFillRectDecal({WIDTH/6,HEIGHT/6*3},{WIDTH/3,HEIGHT/6*2},olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,0));
GradientFillRectDecal({WIDTH/6*3+1,HEIGHT/6*3},{WIDTH/3,HEIGHT/6*2},olc::Pixel(72, 160, 212,0),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255),olc::Pixel(72, 160, 212,255));
}break;
}
if (messageBoxVisible) { if (messageBoxVisible) {
DrawDialogBox({4,HEIGHT-60},{WIDTH/2,16},olc::Pixel(18, 0, 33,180)); DrawDialogBox({4,HEIGHT-60},{WIDTH/2,16},olc::Pixel(18, 0, 33,180));
DrawDialogBox({0,HEIGHT-48},{WIDTH,48},olc::Pixel(18, 0, 33,180)); DrawDialogBox({0,HEIGHT-48},{WIDTH,48},olc::Pixel(18, 0, 33,180));

Binary file not shown.
Loading…
Cancel
Save