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

@ -4,7 +4,7 @@
#define OLC_PGEX_SPLASHSCREEN
#include "splash.h"
using namespace std;
using namespace olc;
enum GAMESTATE{
CUTSCENE_1,
@ -14,13 +14,15 @@ enum GAMESTATE{
WAITING_FOR_CUTSCENE_3,
};
enum CUTSCENE{
NONE,
PAN_DOME,
PAUSE_TO_CUTSCENE_3,
CUTSCENE_4,
TRANSITION_CUTSCENE,
};
namespace cutscene{
enum CUTSCENE{
NONE,
PAN_DOME,
PAUSE_TO_CUTSCENE_3,
CUTSCENE_4,
TRANSITION_CUTSCENE,
};
}
namespace battle{
enum BATTLESTATE{
@ -45,15 +47,15 @@ namespace battle{
class Animation{
public:
olc::Decal*spr;
std::vector<olc::vi2d> frames;
Decal*spr;
std::vector<vi2d> frames;
int frame=0;
bool flipped=false;
int skip_frames=1; //Essentially the animation speed. Number of frames to wait for next frame.
int width=32;
int height=32;
olc::vi2d getCurrentFrame() {
vi2d getCurrentFrame() {
return frames[frame];
}
};
@ -62,13 +64,13 @@ std::vector<Animation*> updateAnimationsList; //Used to store animations in the
class ObjectLoadInfo{
public:
olc::Decal*spr;
Decal*spr;
bool hasanim=false;
Animation*anim;
ObjectLoadInfo(olc::Decal*spr) {
ObjectLoadInfo(Decal*spr) {
this->spr=spr;
}
ObjectLoadInfo(olc::Decal*spr,Animation*anim) {
ObjectLoadInfo(Decal*spr,Animation*anim) {
this->spr=spr;
this->anim=anim;
this->hasanim=true;
@ -79,23 +81,44 @@ class ObjectLoadInfo{
class Object{
public:
float x,y;
olc::Decal*spr;
Decal*spr;
std::string name;
bool hasAnim=false;
Animation*anim;
};
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;
}
};
class Entity{
public:
bool ally;
int hp;
int maxhp;
olc::Decal*spr;
Decal*spr;
int x;
int y;
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(Decal*spr,std::string name,int x,int y,int hp,int maxhp,bool isAlly=false) {
this->spr=spr;
this->name=name;
this->x=x;
@ -112,37 +135,7 @@ class Encounter{
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 PixelGameEngine
{
public:
SeasonsOfLoneliness()
@ -167,11 +160,11 @@ public:
int**MAP=NULL;
int MAP_WIDTH=-1;
int MAP_HEIGHT=-1;
olc::Decal*TILES;
Decal*TILES;
float PLAYER_COORDS[2] = {14,4};
std::vector<Object> OBJECTS;
bool CUTSCENE_ACTIVE=false;
CUTSCENE CURRENT_CUTSCENE=NONE;
cutscene::CUTSCENE CURRENT_CUTSCENE=cutscene::NONE;
int CUTSCENE_TIMER=0;
bool CUTSCENE_FLAGS[8];
bool messageBoxVisible=false;
@ -186,7 +179,7 @@ public:
bool oxygenMeterVisible=false;
int oxygenQualityLevel=34;
int plantState=0b10010110101000101010100110101010;
olc::SplashScreen splash;
SplashScreen splash;
Animation current_playerAnim;
Animation playerAnim;
Animation playerAnimRight;
@ -217,27 +210,19 @@ public:
bool IN_BATTLE_ENCOUNTER = false;
int BATTLE_ENTRY_TIMER = 0;
int EFFECT_TIMER = 0;
#define WEATHER_POWER_COUNT 15 //Number of powers that are in the game. Update storage array accordingly.
#define WEATHER_POWER_COUNT 5 //Number of powers that are in the game. Update storage array accordingly.
WEATHER_POWER*WEATHER_POWERS[WEATHER_POWER_COUNT] = {
HAILSTORM,
HURRICANE,
METEOR_SHOWER,
METEOR_STORM,
SNOWSTORM,
0,
0,
0,
0,
0,
0,
0,
0,0,0};
SNOWSTORM,};
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,
Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL,*PLANT_DECAL,
*PLAYER_DECAL,
*WEATHERNODE_EFFECT_DECAL,*POWER_HAILSTORM_DECAL,*POWER_HURRICANE_DECAL,*POWER_METEOR_SHOWER_DECAL,*POWER_METEOR_STORM_DECAL,*POWER_SNOWSTORM_DECAL,
*SPIDEY_DECAL;
@ -248,23 +233,23 @@ public:
bool OnUserCreate() override
{
SetPixelMode(olc::Pixel::ALPHA);
SetPixelMode(Pixel::ALPHA);
ConsoleCaptureStdOut(true);
//ConsoleShow(olc::F1,false);
//ConsoleShow(F1,false);
// Called once at the start, so create things here
TILES=new olc::Decal(new olc::Sprite("assets/tiles.png"));
DOME_DECAL=new olc::Decal(new olc::Sprite("assets/dome.png"));
FOOD_METER_DECAL=new olc::Decal(new olc::Sprite("assets/corn.png"));
OXYGEN_METER_DECAL=new olc::Decal(new olc::Sprite("assets/co2.png"));
PLANT_DECAL=new olc::Decal(new olc::Sprite("assets/plant.png"));
PLAYER_DECAL=new olc::Decal(new olc::Sprite("assets/player.png"));
WEATHERNODE_EFFECT_DECAL=new olc::Decal(new olc::Sprite("assets/weathernode_effect.png"));
POWER_HAILSTORM_DECAL=new olc::Decal(new olc::Sprite("assets/hailstorm_icon.png"));
POWER_HURRICANE_DECAL=new olc::Decal(new olc::Sprite("assets/hurricane_icon.png"));
POWER_METEOR_SHOWER_DECAL=new olc::Decal(new olc::Sprite("assets/meteor_shower_icon.png"));
POWER_METEOR_STORM_DECAL=new olc::Decal(new olc::Sprite("assets/meteor_storm.png"));
POWER_SNOWSTORM_DECAL=new olc::Decal(new olc::Sprite("assets/snowstorm_icon.png"));
SPIDEY_DECAL=new olc::Decal(new olc::Sprite("assets/spidey.png"));
TILES=new Decal(new Sprite("assets/tiles.png"));
DOME_DECAL=new Decal(new Sprite("assets/dome.png"));
FOOD_METER_DECAL=new Decal(new Sprite("assets/corn.png"));
OXYGEN_METER_DECAL=new Decal(new Sprite("assets/co2.png"));
PLANT_DECAL=new Decal(new Sprite("assets/plant.png"));
PLAYER_DECAL=new Decal(new Sprite("assets/player.png"));
WEATHERNODE_EFFECT_DECAL=new Decal(new Sprite("assets/weathernode_effect.png"));
POWER_HAILSTORM_DECAL=new Decal(new Sprite("assets/hailstorm_icon.png"));
POWER_HURRICANE_DECAL=new Decal(new Sprite("assets/hurricane_icon.png"));
POWER_METEOR_SHOWER_DECAL=new Decal(new Sprite("assets/meteor_shower_icon.png"));
POWER_METEOR_STORM_DECAL=new Decal(new Sprite("assets/meteor_storm.png"));
POWER_SNOWSTORM_DECAL=new Decal(new Sprite("assets/snowstorm_icon.png"));
SPIDEY_DECAL=new Decal(new Sprite("assets/spidey.png"));
current_playerAnim.spr=PLAYER_DECAL;
playerAnim.spr=PLAYER_DECAL;
@ -356,8 +341,8 @@ public:
}
void GetAnyKeyPress() override {
if (!GetKey(olc::W).bPressed&&!GetKey(olc::A).bPressed&&!GetKey(olc::S).bPressed&&!GetKey(olc::D).bPressed&&
!GetKey(olc::UP).bPressed&&!GetKey(olc::RIGHT).bPressed&&!GetKey(olc::DOWN).bPressed&&!GetKey(olc::LEFT).bPressed) {
if (!GetKey(W).bPressed&&!GetKey(A).bPressed&&!GetKey(S).bPressed&&!GetKey(D).bPressed&&
!GetKey(UP).bPressed&&!GetKey(RIGHT).bPressed&&!GetKey(DOWN).bPressed&&!GetKey(LEFT).bPressed) {
ActionButtonPress();
}
if (messageBoxVisible) {
@ -399,35 +384,35 @@ public:
elapsedTime-=TARGET_RATE;
updateGame();
}
if (GetKey(olc::F1).bPressed) {
ConsoleShow(olc::F1,false);
if (GetKey(F1).bPressed) {
ConsoleShow(F1,false);
}
if (GetKey(olc::D).bPressed||GetKey(olc::RIGHT).bPressed||GetKey(olc::NP6).bPressed) {
if (GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed) {
changeAnimation(playerAnimWalkRight);
}
if (GetKey(olc::A).bPressed||GetKey(olc::LEFT).bPressed||GetKey(olc::NP4).bPressed) {
if (GetKey(A).bPressed||GetKey(LEFT).bPressed||GetKey(NP4).bPressed) {
changeAnimation(playerAnimWalkLeft);
}
if (GetKey(olc::W).bPressed||GetKey(olc::UP).bPressed||GetKey(olc::NP8).bPressed) {
if (GetKey(W).bPressed||GetKey(UP).bPressed||GetKey(NP8).bPressed) {
changeAnimation(playerAnimWalkUp);
}
if (GetKey(olc::S).bPressed||GetKey(olc::DOWN).bPressed||GetKey(olc::NP5).bPressed||GetKey(olc::NP2).bPressed) {
if (GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed) {
changeAnimation(playerAnimWalkDown);
}
if (!GetKey(olc::D).bHeld&&!GetKey(olc::RIGHT).bHeld&&!GetKey(olc::NP6).bHeld&&
!GetKey(olc::A).bHeld&&!GetKey(olc::LEFT).bHeld&&!GetKey(olc::NP4).bHeld&&
!GetKey(olc::S).bHeld&&!GetKey(olc::UP).bHeld&&!GetKey(olc::NP8).bHeld&&
!GetKey(olc::W).bHeld&&!GetKey(olc::DOWN).bHeld&&!GetKey(olc::NP5).bHeld&&!GetKey(olc::NP2).bHeld) {
if (GetKey(olc::D).bReleased||GetKey(olc::RIGHT).bReleased||GetKey(olc::NP6).bReleased) {
if (!GetKey(D).bHeld&&!GetKey(RIGHT).bHeld&&!GetKey(NP6).bHeld&&
!GetKey(A).bHeld&&!GetKey(LEFT).bHeld&&!GetKey(NP4).bHeld&&
!GetKey(S).bHeld&&!GetKey(UP).bHeld&&!GetKey(NP8).bHeld&&
!GetKey(W).bHeld&&!GetKey(DOWN).bHeld&&!GetKey(NP5).bHeld&&!GetKey(NP2).bHeld) {
if (GetKey(D).bReleased||GetKey(RIGHT).bReleased||GetKey(NP6).bReleased) {
changeAnimation(playerAnimRight);
}
if (GetKey(olc::A).bReleased||GetKey(olc::LEFT).bReleased||GetKey(olc::NP4).bReleased) {
if (GetKey(A).bReleased||GetKey(LEFT).bReleased||GetKey(NP4).bReleased) {
changeAnimation(playerAnimLeft);
}
if (GetKey(olc::W).bReleased||GetKey(olc::UP).bReleased||GetKey(olc::NP8).bReleased) {
if (GetKey(W).bReleased||GetKey(UP).bReleased||GetKey(NP8).bReleased) {
changeAnimation(playerAnim);
}
if (GetKey(olc::S).bReleased||GetKey(olc::DOWN).bReleased||GetKey(olc::NP5).bReleased||GetKey(olc::NP2).bReleased) {
if (GetKey(S).bReleased||GetKey(DOWN).bReleased||GetKey(NP5).bReleased||GetKey(NP2).bReleased) {
changeAnimation(playerAnimDown);
}
}
@ -441,17 +426,17 @@ public:
switch (GAME_STATE) {
case CUTSCENE_1:{
GAME_STATE=CUTSCENE_2;
PlayCutscene(PAN_DOME);
PlayCutscene(cutscene::PAN_DOME);
fadeIn();
}break;
case CUTSCENE_2:{
fadeIn();
PlayCutscene(CUTSCENE_4);
PlayCutscene(cutscene::CUTSCENE_4);
GAME_STATE=GAMEWORLD;
}break;
}
switch (CURRENT_CUTSCENE) {
case TRANSITION_CUTSCENE:{
case cutscene::TRANSITION_CUTSCENE:{
LoadMap("assets/maps/map1");
PLAYER_COORDS[0]=40;
PLAYER_COORDS[1]=37;
@ -465,18 +450,18 @@ public:
}
void PlayCutscene(CUTSCENE scene) {
void PlayCutscene(cutscene::CUTSCENE scene) {
CURRENT_CUTSCENE=scene;
switch (scene) {
case PAN_DOME:{
case cutscene::PAN_DOME:{
PLAYER_COORDS[0]=14;
PLAYER_COORDS[1]=35+(64/2/32);
}break;
case PAUSE_TO_CUTSCENE_3:{
case cutscene::PAUSE_TO_CUTSCENE_3:{
CUTSCENE_CONSOLE_TEXT.clear();
textInd=0;
}break;
case CUTSCENE_4:{
case cutscene::CUTSCENE_4:{
LoadMap("assets/maps/map2");
PLAYER_COORDS[0]=16;
PLAYER_COORDS[1]=6;
@ -494,13 +479,13 @@ public:
CUTSCENE_TIMER++;
}
if (fade&&transparency<255) {
transparency=clamp(transparency+FADE_SPD,0,255);
transparency=std::clamp(transparency+FADE_SPD,0,255);
if (transparency==255) {
fadeOutCompleted();
}
} else
if (!fade&&transparency>0) {
transparency=clamp(transparency-FADE_SPD,0,255);
transparency=std::clamp(transparency-FADE_SPD,0,255);
if (transparency==0) {
fadeInCompleted();
}
@ -523,8 +508,8 @@ public:
if (CURRENT_CUTSCENE==NONE&&!messageBoxVisible&&!IN_BATTLE_ENCOUNTER) {
bool changed=false;
if (GetKey(olc::D).bHeld||GetKey(olc::RIGHT).bHeld||GetKey(olc::NP6).bHeld) {
PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]+MOVE_SPD,0.1,(double)MAP_WIDTH);
if (GetKey(D).bHeld||GetKey(RIGHT).bHeld||GetKey(NP6).bHeld) {
PLAYER_COORDS[0]=std::clamp(PLAYER_COORDS[0]+MOVE_SPD,0.1,(double)MAP_WIDTH);
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if (!changed&&&current_playerAnim!=&playerAnimWalkRight) {
@ -532,8 +517,8 @@ public:
changed=true;
}
}
if (GetKey(olc::A).bHeld||GetKey(olc::LEFT).bHeld||GetKey(olc::NP4).bHeld) {
PLAYER_COORDS[0]=clamp(PLAYER_COORDS[0]-MOVE_SPD,0.1,(double)MAP_WIDTH);
if (GetKey(A).bHeld||GetKey(LEFT).bHeld||GetKey(NP4).bHeld) {
PLAYER_COORDS[0]=std::clamp(PLAYER_COORDS[0]-MOVE_SPD,0.1,(double)MAP_WIDTH);
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if (!changed&&&current_playerAnim!=&playerAnimWalkLeft) {
@ -541,8 +526,8 @@ public:
changed=true;
}
}
if (GetKey(olc::W).bHeld||GetKey(olc::UP).bHeld||GetKey(olc::NP8).bHeld) {
PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]-MOVE_SPD,0.1,(double)MAP_HEIGHT);
if (GetKey(W).bHeld||GetKey(UP).bHeld||GetKey(NP8).bHeld) {
PLAYER_COORDS[1]=std::clamp(PLAYER_COORDS[1]-MOVE_SPD,0.1,(double)MAP_HEIGHT);
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if (!changed&&&current_playerAnim!=&playerAnimWalkUp) {
@ -550,8 +535,8 @@ public:
changed=true;
}
}
if (GetKey(olc::S).bHeld||GetKey(olc::DOWN).bHeld||GetKey(olc::NP5).bHeld||GetKey(olc::NP2).bHeld) {
PLAYER_COORDS[1]=clamp(PLAYER_COORDS[1]+MOVE_SPD,0.1,(double)MAP_HEIGHT);
if (GetKey(S).bHeld||GetKey(DOWN).bHeld||GetKey(NP5).bHeld||GetKey(NP2).bHeld) {
PLAYER_COORDS[1]=std::clamp(PLAYER_COORDS[1]+MOVE_SPD,0.1,(double)MAP_HEIGHT);
//ConsoleClear();
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
if (!changed&&&current_playerAnim!=&playerAnimWalkDown) {
@ -566,36 +551,36 @@ public:
if (obj.name.compare("HAILSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
HAILSTORM->playerOwnCount+=amountGained;
cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n";
std::cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
} else
if (obj.name.compare("HURRICANE_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
HURRICANE->playerOwnCount+=amountGained;
cout<<"Increased HURRICANE power inventory count by "<<amountGained<<".\n";
std::cout<<"Increased HURRICANE power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
} else
if (obj.name.compare("METEORSHOWER_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
METEOR_SHOWER->playerOwnCount+=amountGained;
cout<<"Increased METEORSHOWER power inventory count by "<<amountGained<<".\n";
std::cout<<"Increased METEORSHOWER power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
} else
if (obj.name.compare("METEORSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
METEOR_STORM->playerOwnCount+=amountGained;
cout<<"Increased METEORSTORM power inventory count by "<<amountGained<<".\n";
std::cout<<"Increased METEORSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
} else
if (obj.name.compare("SNOWSTORM_NODE")==0&&collidesWithPlayer(obj)) {
int amountGained=rand()%4+2;
SNOWSTORM->playerOwnCount+=amountGained;
cout<<"Increased SNOWSTORM power inventory count by "<<amountGained<<".\n";
std::cout<<"Increased SNOWSTORM power inventory count by "<<amountGained<<".\n";
OBJECTS.erase(OBJECTS.begin()+i--);
}
if (obj.name.compare("EXIT")==0&&collidesWithPlayer(obj)) {
fadeOut();
PlayCutscene(TRANSITION_CUTSCENE);
PlayCutscene(cutscene::TRANSITION_CUTSCENE);
}
}
@ -611,7 +596,7 @@ public:
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";
//cout<<"There are x"<<WEATHER_POWERS[i]->playerOwnCount<<" of "<<WEATHER_POWERS[i]->name<<"\n";
}
}
BATTLE_CARD_SELECTION=availablePowers[0];
@ -662,7 +647,7 @@ public:
}
switch (CURRENT_CUTSCENE) {
case CUTSCENE_4:{
case cutscene::CUTSCENE_4:{
if (!messageBoxVisible) {
if (!CUTSCENE_FLAGS[0]) {
CUTSCENE_FLAGS[0]=true;
@ -779,11 +764,11 @@ public:
void drawGame(){
switch (GAME_STATE) {
case CUTSCENE_1:{
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,olc::GREEN,{1,1});
DrawStringDecal({16,16},CUTSCENE_CONSOLE_TEXT,GREEN,{1,1});
if (textInd<STORY_TEXT1.length()) {
FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},olc::GREEN);
FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},GREEN);
} else {
FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},olc::Pixel(0,255,0,(0.5*sin(frameCount*4/60.0)+0.5)*256));
FillRectDecal({(float)(16+(cursorX)*8%(WIDTH-32)),(float)(8+GetTextSize(CUTSCENE_CONSOLE_TEXT).y+((cursorX==28)?8:0))},{4,8},Pixel(0,255,0,(0.5*sin(frameCount*4/60.0)+0.5)*256));
}
GradientFillRectDecal({0,0},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1});
GradientFillRectDecal({WIDTH/2,0},{WIDTH/2,HEIGHT/2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN2},{20, 28, 22,ALPHA_SCREEN1},{20, 28, 22,ALPHA_SCREEN1});
@ -796,29 +781,29 @@ public:
int meterYOffset=2;
if (CURRENT_CUTSCENE==NONE) {
if (foodMeterVisible) {
DrawStringDecal({WIDTH-36*0.4-GetTextSize(to_string(foodCount)).x*1-8,meterYOffset+2},to_string(foodCount),olc::BLUE,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(to_string(foodCount)).x*1-7,meterYOffset+2},to_string(foodCount),olc::BLACK,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(std::to_string(foodCount)).x*1-8,meterYOffset+2},std::to_string(foodCount),BLUE,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(std::to_string(foodCount)).x*1-7,meterYOffset+2},std::to_string(foodCount),BLACK,{1,1});
DrawDecal({WIDTH-52*0.4,meterYOffset},FOOD_METER_DECAL,{0.4,0.4});
meterYOffset+=(2+48*0.4);
}
if (oxygenMeterVisible) {
DrawStringDecal({WIDTH-36*0.4-GetTextSize(to_string(oxygenQualityLevel)+"%").x*1-8,meterYOffset+2},to_string(oxygenQualityLevel)+"%",olc::BLUE,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(to_string(oxygenQualityLevel)+"%").x*1-7,meterYOffset+2},to_string(oxygenQualityLevel)+"%",olc::BLACK,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(std::to_string(oxygenQualityLevel)+"%").x*1-8,meterYOffset+2},std::to_string(oxygenQualityLevel)+"%",BLUE,{1,1});
DrawStringDecal({WIDTH-36*0.4-GetTextSize(std::to_string(oxygenQualityLevel)+"%").x*1-7,meterYOffset+2},std::to_string(oxygenQualityLevel)+"%",BLACK,{1,1});
DrawDecal({WIDTH-52*0.4,meterYOffset},OXYGEN_METER_DECAL,{0.4,0.4});
meterYOffset+=(2+48*0.4);
}
DrawPartialDecal({WIDTH/2-16+(current_playerAnim.flipped?32:0),HEIGHT/2-16},current_playerAnim.spr,current_playerAnim.getCurrentFrame(),{32,32},{current_playerAnim.flipped?-1:1,1});
if (IN_BATTLE_ENCOUNTER&&BATTLE_ENTRY_TIMER<45) {
DrawStringDecal({WIDTH/2-16+(current_playerAnim.flipped?32:0)+8,HEIGHT/2-16-sin(frameCount*12/60.0)*4-12},"!!",olc::RED);
DrawStringDecal({WIDTH/2-16+(current_playerAnim.flipped?32:0)+8,HEIGHT/2-16-sin(frameCount*12/60.0)*4-12},"!!",RED);
}
}
}break;
case CUTSCENE_3:{
DrawStringDecal({48,16},CUTSCENE_CONSOLE_TEXT,olc::Pixel(100, 10, 255),{2,2});
DrawStringDecal({48,16},CUTSCENE_CONSOLE_TEXT,Pixel(100, 10, 255),{2,2});
if (textInd<STORY_TEXT2.length()) {
FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},olc::Pixel(100, 10, 255));
FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},Pixel(100, 10, 255));
} else {
FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},olc::Pixel(100, 10, 255,(0.5*sin(frameCount*4/60.0)+0.5)*256));
FillRectDecal({(float)(48+(cursorX)*16%(WIDTH-32)),(float)(GetTextSize(CUTSCENE_CONSOLE_TEXT).y*2+((cursorX==28)?16:0))},{4*2,8*2},Pixel(100, 10, 255,(0.5*sin(frameCount*4/60.0)+0.5)*256));
}
GradientFillRectDecal({0,0},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1});
GradientFillRectDecal({WIDTH/2,0},{WIDTH/2,HEIGHT/2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN2},{100, 10, 255,ALPHA_SCREEN1},{100, 10, 255,ALPHA_SCREEN1});
@ -828,23 +813,42 @@ public:
}
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));
GradientFillRectDecal({WIDTH/6,HEIGHT/6},{WIDTH/3,HEIGHT/6*2},Pixel(72, 160, 212,255),Pixel(72, 160, 212,255),Pixel(72, 160, 212,0),Pixel(72, 160, 212,255));
GradientFillRectDecal({WIDTH/6*3+1,HEIGHT/6},{WIDTH/3,HEIGHT/6*2},Pixel(72, 160, 212,255),Pixel(72, 160, 212,0),Pixel(72, 160, 212,255),Pixel(72, 160, 212,255));
GradientFillRectDecal({WIDTH/6,HEIGHT/6*3},{WIDTH/3,HEIGHT/6*2},Pixel(72, 160, 212,255),Pixel(72, 160, 212,255),Pixel(72, 160, 212,255),Pixel(72, 160, 212,0));
GradientFillRectDecal({WIDTH/6*3+1,HEIGHT/6*3},{WIDTH/3,HEIGHT/6*2},Pixel(72, 160, 212,0),Pixel(72, 160, 212,255),Pixel(72, 160, 212,255),Pixel(72, 160, 212,255));
DrawPartialDecal({WIDTH/2-BATTLE_CARD_SELECTION->anim->width/2*3,HEIGHT/6+16-BATTLE_CARD_SELECTION->anim->height/2},BATTLE_CARD_SELECTION->anim->spr,BATTLE_CARD_SELECTION->anim->getCurrentFrame(),{BATTLE_CARD_SELECTION->anim->width,BATTLE_CARD_SELECTION->anim->height},{3,3});
for (int x=-1;x<=1;x++) {
for (int y=-1;y<=1;y++) {
if (x!=0&&y!=0) {
DrawStringPropDecal({WIDTH/6+4+x,HEIGHT/2+8+y},BATTLE_CARD_SELECTION->name,BLACK,{2,2});
}
}
}
DrawStringPropDecal({WIDTH/6+4,HEIGHT/2+8},BATTLE_CARD_SELECTION->name,Pixel(93, 161, 163,255),{2,2});
DrawWrappedPropText({WIDTH/6+4+1,HEIGHT/2+24+1},BATTLE_CARD_SELECTION->description,WIDTH/3*2-8,BLACK,{1,1});
DrawWrappedPropText({WIDTH/6+4,HEIGHT/2+24},BATTLE_CARD_SELECTION->description,WIDTH/3*2-8,Pixel(227, 245, 255,255),{1,1});
for (int x=-1;x<=1;x++) {
for (int y=-1;y<=1;y++) {
if (x!=0&&y!=0) {
DrawStringPropDecal({WIDTH/6+4+x,HEIGHT/2+8+y},BATTLE_CARD_SELECTION->name,BLACK,{2,2});
}
}
}
DrawStringPropDecal({WIDTH/6+4,HEIGHT/2+8},std::to_string(BATTLE_CARD_SELECTION->playerOwnCount),Pixel(93, 161, 163,255),{2,2});
}break;
}
if (messageBoxVisible) {
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({4,HEIGHT-60},{WIDTH/2,16},Pixel(18, 0, 33,180));
DrawDialogBox({0,HEIGHT-48},{WIDTH,48},Pixel(18, 0, 33,180));
DrawStringPropDecal({8,HEIGHT-40},messageBoxText);
DrawStringPropDecal({8,HEIGHT-57},messageBoxSpeaker);
if (messageBoxCursor==messageBoxRefText.length()) {
DrawStringPropDecal({WIDTH-16-(float)sin(frameCount*8/60.0)*3,HEIGHT-8+(float)(cos(frameCount*6/60.0)*0.6)},"v",olc::Pixel(173, 74, 255,(0.5*sin(frameCount*8/60.0)+0.5)*128+128),{(float)sin(frameCount*8/60.0),0.5});
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});
}
}
FillRectDecal({0,0},{WIDTH,HEIGHT},olc::Pixel(0,0,0,transparency));
//FillRectDecal({WIDTH/2-2,HEIGHT/2-2},{4,4},olc::WHITE);
FillRectDecal({0,0},{WIDTH,HEIGHT},Pixel(0,0,0,transparency));
//FillRectDecal({WIDTH/2-2,HEIGHT/2-2},{4,4},WHITE);
}
void DrawGameWorld() {
@ -873,7 +877,7 @@ public:
} else {
if (obj.name.find("NODE")!=std::string::npos) {
DrawDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2-32+18,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2-32+26},WEATHERNODE_EFFECT_DECAL);
DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2-16*(float)sin(frameCount*2/60.0)+16,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.anim->spr,{obj.anim->getCurrentFrame().x,obj.anim->getCurrentFrame().y},{obj.anim->width,obj.anim->height},{(float)sin(frameCount*2/60.0),1},olc::Pixel((float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0+M_PI)+65*125,255));
DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2-16*(float)sin(frameCount*2/60.0)+16,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.anim->spr,{obj.anim->getCurrentFrame().x,obj.anim->getCurrentFrame().y},{obj.anim->width,obj.anim->height},{(float)sin(frameCount*2/60.0),1},Pixel((float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0)*55+200,(float)sin(frameCount*4/60.0+M_PI)+65*125,255));
} else
if (obj.hasAnim) {
DrawPartialDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2+(obj.anim->flipped?32:0),(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},obj.anim->spr,{obj.anim->getCurrentFrame().x,obj.anim->getCurrentFrame().y},{obj.anim->width,obj.anim->height},{obj.anim->flipped?-1:1,1});
@ -883,7 +887,7 @@ public:
}
} else
if (obj.name.compare("EXIT")==0) {
GradientFillRectDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},olc::Pixel(0,0,0,0),olc::WHITE,olc::WHITE,olc::Pixel(0,0,0,0));
GradientFillRectDecal({(obj.x-PLAYER_COORDS[0])*32+WIDTH/2,(obj.y-PLAYER_COORDS[1])*32+HEIGHT/2},{32,32},Pixel(0,0,0,0),WHITE,WHITE,Pixel(0,0,0,0));
}
}
for (auto&enc:ENCOUNTERS) {
@ -908,15 +912,15 @@ public:
plantState&=numb;
}
void DrawDialogBox(const olc::vi2d &pos, const olc::vi2d &size, olc::Pixel p = olc::WHITE, olc::Pixel p2 = olc::DARK_GREY, olc::Pixel p3 = olc::VERY_DARK_GREY) {
void DrawDialogBox(const vi2d &pos, const vi2d &size, Pixel p = WHITE, Pixel p2 = DARK_GREY, Pixel p3 = VERY_DARK_GREY) {
FillRectDecal({(float)pos.x,(float)pos.y},size,p2);
FillRectDecal({(float)pos.x+1,(float)pos.y+1},{(float)size.x-2,(float)size.y-2},p);
FillRectDecal({(float)pos.x+2,(float)pos.y+2},{(float)size.x-4,(float)size.y-4},p3);
FillRectDecal({(float)pos.x+3,(float)pos.y+3},{(float)size.x-5,(float)size.y-5},p);
Draw({pos.x,pos.y},olc::BLACK);
Draw({pos.x+size.x,pos.y+size.y},olc::BLACK);
Draw({pos.x+size.x,pos.y},olc::BLACK);
Draw({pos.x,pos.y+size.y},olc::BLACK);
Draw({pos.x,pos.y},BLACK);
Draw({pos.x+size.x,pos.y+size.y},BLACK);
Draw({pos.x+size.x,pos.y},BLACK);
Draw({pos.x,pos.y+size.y},BLACK);
}
void fadeOut() {
@ -927,7 +931,7 @@ public:
}
void EndCutscene() {
CURRENT_CUTSCENE=NONE;
CURRENT_CUTSCENE=cutscene::NONE;
}
void DisplayMessageBox(int dialogNumber) {
@ -1031,6 +1035,27 @@ public:
return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+WIDTH/32&&
PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+HEIGHT/32;
}
void DrawWrappedPropText(vf2d pos,std::string text,int targetWidth,Pixel col,vf2d scale) {
std::string wrappedText;
int marker=0;
while (marker<text.length()) {
wrappedText+=text[marker];
if (GetTextSizeProp(wrappedText).x>targetWidth*scale.x) {
int tempMarker=marker;
while (wrappedText[tempMarker]!=' ') {
wrappedText.erase(tempMarker--);
}
wrappedText.erase(tempMarker++);
wrappedText+='\n';
while (tempMarker<marker+1) {
wrappedText+=text[tempMarker++];
}
}
marker++;
}
DrawStringPropDecal(pos,wrappedText,col,scale);
}
};

Binary file not shown.
Loading…
Cancel
Save