Include some particle effects and behaviors

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 0952608ee2
commit fb95a29be5
  1. 176
      SeasonsOfLoneliness.cpp
  2. BIN
      Seasons_of_Loneliness

@ -23,6 +23,7 @@ namespace cutscene{
PAUSE_TO_CUTSCENE_3,
CUTSCENE_4,
TRANSITION_CUTSCENE,
NODE_COLLECT_CUTSCENE
};
}
@ -105,6 +106,35 @@ class Object{
Animation*anim;
};
class ParticleEffect{
public:
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;
ParticleEffect(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) {
this->effectPos=effectPos;
this->effectSize=effectSize;
this->pos_low=pos_low;
this->pos_high=pos_high;
this->size_low=size_high;
this->spd_low=spd_low;
this->spd_high=spd_high;
this->col_low=col_low;
this->col_high=col_high;
this->amt=amt;
this->foregroundColor=foregroundColor;
}
};
class WEATHER_POWER{
public:
std::string description;
@ -118,7 +148,8 @@ class WEATHER_POWER{
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) {
ParticleEffect*effect;
WEATHER_POWER(std::string name,std::string desc,Animation*icon,Animation*effect,int dmg,int dmgRoll,int range,Pixel bgcol,Pixel textcol,int effectTime,ParticleEffect*parteff) {
this->description=desc;
this->name=name;
this->anim=icon;
@ -129,6 +160,7 @@ class WEATHER_POWER{
this->bgcol=bgcol;
this->textcol=textcol;
this->effectTime=effectTime;
this->effect=parteff;
}
};
@ -165,6 +197,26 @@ class Encounter{
std::vector<int> turnOrder;
};
namespace effect {
class Pixel{
public:
vf2d pos, size, spd;
olc::Pixel col;
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;
}
};
};
class SeasonsOfLoneliness : public PixelGameEngine
{
public:
@ -230,16 +282,25 @@ public:
Animation POWER_SNOWSTORM_ANIMATION;
Animation CONSUME_SNACK_ANIMATION;
Animation CONSUME_MEAL_ANIMATION;
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),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),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),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),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),120);
WEATHER_POWER*SEED_STORM = new WEATHER_POWER("Seed Storm","",&POWER_HAILSTORM_ANIMATION,&POWER_HAILSTORM_ANIMATION,-10,15,30,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),120);
WEATHER_POWER*CONSUME_SNACK = new WEATHER_POWER("Snack","Restores 33% health for 5 turns. If battle ends before effect ends, food is not consumed.",&CONSUME_SNACK_ANIMATION,&CONSUME_SNACK_ANIMATION,-1001,1,200,Pixel(147, 173, 66,255),Pixel(255, 188, 3,255),120);
WEATHER_POWER*CONSUME_MEAL = new WEATHER_POWER("Meal","Restores all health. Increases Maximum Health by 5.",&CONSUME_MEAL_ANIMATION,&CONSUME_MEAL_ANIMATION,-1002,1,200,Pixel(147, 173, 66,255),Pixel(255, 188, 3,255),120);
ParticleEffect*HAILSTORM_EFF = new ParticleEffect({0,0},{WIDTH,HEIGHT},{0,0},{WIDTH,HEIGHT},{1,1},{4,4},{-0.2,0.05},{-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.02},{-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.01},{-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.05},{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.05,-0.1},{0.05,-0.02},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.01,-0.05},{0.01,-0.005},Pixel(255,255,255,130),Pixel(255,255,255,210),30,Pixel(147, 161, 90,64)); //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);
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,METEOR_RAIN_EFF);
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,SNOWSTORM_EFF);
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,SANDSTORM_EFF);
WEATHER_POWER*SEED_STORM = new WEATHER_POWER("Seed Storm","",&POWER_HAILSTORM_ANIMATION,&POWER_HAILSTORM_ANIMATION,-10,15,30,Pixel(93, 161, 163,255),Pixel(72, 160, 212,255),120,SEED_STORM_EFF);
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,AVALANCHE_EFF);
WEATHER_POWER*CONSUME_SNACK = new WEATHER_POWER("Snack","Restores 33% health for 5 turns. If battle ends before effect ends, food is not consumed.",&CONSUME_SNACK_ANIMATION,&CONSUME_SNACK_ANIMATION,-1001,1,200,Pixel(147, 173, 66,255),Pixel(255, 188, 3,255),120,CONSUME_SNACK_EFF);
WEATHER_POWER*CONSUME_MEAL = new WEATHER_POWER("Meal","Restores all health. Increases Maximum Health by 5.",&CONSUME_MEAL_ANIMATION,&CONSUME_MEAL_ANIMATION,-1002,1,200,Pixel(147, 173, 66,255),Pixel(255, 188, 3,255),120,CONSUME_SNACK_EFF);
bool IN_BATTLE_ENCOUNTER = false;
int BATTLE_ENTRY_TIMER = 0;
int EFFECT_TIMER = 0;
@ -265,7 +326,11 @@ public:
std::vector<DisplayNumber*> BATTLE_DISPLAY_NUMBERS;
bool PLAYER_TURN_COMPLETE=false;
int FOOD_REGEN_TURNS=0;
WEATHER_POWER* CUTSCENE_DISPLAYED_CARD;
Pixel FOREGROUD_EFFECT_COLOR;
int PIXEL_LIMIT=0;
vf2d PIXEL_POS;
vf2d PIXEL_SIZE;
std::vector<WEATHER_POWER*>MOVESET_SPIDEY;
@ -280,10 +345,20 @@ public:
Encounter CURRENT_ENCOUNTER;
std::queue<int> turnOrder;
#define MAX_PIXELS 500
effect::Pixel pixels[MAX_PIXELS];
bool OnUserCreate() override
{
SetPixelMode(Pixel::ALPHA);
ConsoleCaptureStdOut(true);
#define LAYERS 2 //How many layers exist.
for (int i=0;i<LAYERS-1;i++) {
CreateLayer();
EnableLayer(i,true);
}
//ConsoleShow(F1,false);
// Called once at the start, so create things here
TILES=new Decal(new Sprite("assets/tiles.png"));
@ -467,6 +542,11 @@ public:
setupBattleTurns();
}break;
}
switch (CURRENT_CUTSCENE) {
case cutscene::NODE_COLLECT_CUTSCENE:{
EndCutscene();
}break;
}
}
bool OnUserUpdate(float fElapsedTime) override
@ -550,6 +630,9 @@ public:
}break;
}
}
SetDrawTarget(nullptr);
Clear(BLANK);
SetDrawTarget(1);
drawGame();
// called once per frame
return true;
@ -687,6 +770,7 @@ public:
std::cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
performCropUpdate(8);
displayPowerInfo(HAILSTORM);
} else
if (obj.name.compare("HURRICANE_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
@ -694,6 +778,7 @@ public:
std::cout<<"Increased HURRICANE power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
performCropUpdate(8);
displayPowerInfo(HURRICANE);
} else
if (obj.name.compare("METEORSHOWER_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
@ -701,6 +786,7 @@ public:
std::cout<<"Increased METEORSHOWER power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
performCropUpdate(8);
displayPowerInfo(METEOR_RAIN);
} else
if (obj.name.compare("METEORSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
@ -708,6 +794,7 @@ public:
std::cout<<"Increased METEORSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
performCropUpdate(8);
displayPowerInfo(METEOR_STORM);
} else
if (obj.name.compare("SNOWSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
@ -715,6 +802,7 @@ public:
std::cout<<"Increased SNOWSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
performCropUpdate(8);
displayPowerInfo(SNOWSTORM);
}
if (obj.name.compare("EXIT")==0&&collidesWithPlayer(obj)) {
fadeOut();
@ -831,6 +919,21 @@ public:
effectRadius({PLAYER_COORDS[0],PLAYER_COORDS[1]},ref,false);
}
}
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;
}
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+PIXEL_SIZE.y) {
pixels[i].pos.y=PIXEL_POS.y;
}
}
if (EFFECT_TIMER>ref->effectTime) {
BATTLE_STATE=battle::DAMAGE_RESOLUTION;
EFFECT_TIMER=0;
@ -1070,6 +1173,16 @@ public:
} 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});
}
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);
} else {
FillRectDecal(pixels[i].pos,pixels[i].size,pixels[i].col);
}
}
SetDrawTarget(1);
FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,transparency));
}break;
}
if (IN_BATTLE_ENCOUNTER||(!CUTSCENE_ACTIVE&&PLAYER_HP!=PLAYER_MAXHP)) {
@ -1098,6 +1211,12 @@ public:
DrawStringPropDecal({WIDTH-16-(float)sin(frameCount*8/60.0)*3,HEIGHT-8+(float)(cos(frameCount*6/60.0)*0.6)},"v",Pixel(173, 74, 255,(0.5*sin(frameCount*8/60.0)+0.5)*128+128),{(float)sin(frameCount*8/60.0),0.5});
}
}
switch (CURRENT_CUTSCENE) {
case cutscene::NODE_COLLECT_CUTSCENE:{
FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,128));
DrawCard(CUTSCENE_DISPLAYED_CARD);
}break;
}
FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,transparency));
//FillRectDecal({WIDTH/2-2,HEIGHT/2-2},{4,4},WHITE);
}
@ -1379,7 +1498,7 @@ public:
}
}
}
DrawStringPropDecal({(WIDTH/6+4+WIDTH/3*2-8-GetTextSizeProp(std::to_string(data->playerOwnCount)+" uses remaining.").x*1.5)*scale.x+offset.x,(HEIGHT/6*3+HEIGHT/6*2-GetTextSizeProp(std::to_string(data->playerOwnCount)+" uses remaining.").y*1.5-4)*scale.y+offset.y},std::to_string(data->playerOwnCount)+" uses remaining.",olc::WHITE*darknessFactor*dimColor,{1.5*scale.x,1.5*scale.y});
DrawStringPropDecal({(WIDTH/6+4+WIDTH/3*2-8-GetTextSizeProp(std::to_string(data->playerOwnCount)+" uses remaining.").x*1.5)*scale.x+offset.x,(HEIGHT/6*3+HEIGHT/6*2-GetTextSizeProp(std::to_string(data->playerOwnCount)+" uses remaining.").y*1.5-4)*scale.y+offset.y},std::to_string(data->playerOwnCount)+" uses remaining.",(data->playerOwnCount==0)?olc::RED:olc::WHITE*darknessFactor,{1.5*scale.x,1.5*scale.y});
}
@ -1525,6 +1644,37 @@ public:
BATTLE_STATE=battle::WAIT_TURN_ANIMATION;
EFFECT_TIMER=0;
}
void displayPowerInfo(WEATHER_POWER*POWER){
PlayCutscene(cutscene::NODE_COLLECT_CUTSCENE);
CUTSCENE_DISPLAYED_CARD=POWER;
}
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));
}
FOREGROUD_EFFECT_COLOR=foregroundColor;
PIXEL_POS=effectPos;
PIXEL_SIZE=effectSize;
PIXEL_LIMIT=amt;
}
void clearPixelEffect() {
PIXEL_LIMIT=0;
}
//Returns a number between 0.0 and X.
float random(float X) {
float r2 = static_cast <float> (rand()) / (static_cast <float> (RAND_MAX/X));
}
float range(float val1,float val2) {
return random(val2-val1)+val1;
}
};

Binary file not shown.
Loading…
Cancel
Save