generated from sigonasr2/CPlusPlusProjectTemplate
Prepare for the next BATTLE
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
1bd636d93a
commit
35e9c3d3ee
@ -36,6 +36,7 @@ enum WEATHER_POWER{
|
||||
#define FADE_SPD 6
|
||||
#define MOVE_SPD 0.2
|
||||
#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.
|
||||
|
||||
class Animation{
|
||||
public:
|
||||
@ -84,6 +85,24 @@ class Entity{
|
||||
bool ally;
|
||||
int hp;
|
||||
int maxhp;
|
||||
olc::Decal*spr;
|
||||
int x;
|
||||
int y;
|
||||
std::string name;
|
||||
Entity(olc::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;
|
||||
this->y=y;
|
||||
this->hp=hp;
|
||||
this->maxhp=maxhp;
|
||||
}
|
||||
};
|
||||
|
||||
class Encounter{
|
||||
public:
|
||||
int x,y;
|
||||
std::vector<Entity> entities;
|
||||
};
|
||||
|
||||
class SeasonsOfLoneliness : public olc::PixelGameEngine
|
||||
@ -109,7 +128,7 @@ public:
|
||||
int MAP_WIDTH=-1;
|
||||
int MAP_HEIGHT=-1;
|
||||
olc::Decal*TILES;
|
||||
float PLAYER_COORDS[2] = {};
|
||||
float PLAYER_COORDS[2] = {21,35};
|
||||
std::vector<Object> OBJECTS;
|
||||
bool CUTSCENE_ACTIVE=false;
|
||||
CUTSCENE CURRENT_CUTSCENE=NONE;
|
||||
@ -148,6 +167,7 @@ public:
|
||||
Animation POWER_SNOWSTORM_ANIMATION;
|
||||
std::vector<Entity> entityList;
|
||||
bool IN_BATTLE_ENCOUNTER = false;
|
||||
int BATTLE_ENTRY_TIMER = 0;
|
||||
int WEATHER_POWERS[15] = {
|
||||
3,
|
||||
1,
|
||||
@ -166,8 +186,12 @@ public:
|
||||
|
||||
olc::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;
|
||||
*WEATHERNODE_EFFECT_DECAL,*POWER_HAILSTORM_DECAL,*POWER_HURRICANE_DECAL,*POWER_METEOR_SHOWER_DECAL,*POWER_METEOR_STORM_DECAL,*POWER_SNOWSTORM_DECAL,
|
||||
*SPIDEY_DECAL;
|
||||
std::map<std::string,ObjectLoadInfo*> BASE_OBJECTS;
|
||||
std::vector<Encounter> ENCOUNTERS;
|
||||
Encounter ENCOUNTER_SPIDEY_1;
|
||||
Encounter*CURRENT_ENCOUNTER;
|
||||
|
||||
bool OnUserCreate() override
|
||||
{
|
||||
@ -187,6 +211,7 @@ public:
|
||||
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"));
|
||||
|
||||
current_playerAnim.spr=PLAYER_DECAL;
|
||||
playerAnim.spr=PLAYER_DECAL;
|
||||
@ -254,6 +279,13 @@ public:
|
||||
POWER_SNOWSTORM_ANIMATION.frames.push_back({64,0});
|
||||
POWER_SNOWSTORM_ANIMATION.skip_frames=nodeAnimationSkipFrames;
|
||||
|
||||
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",6,2,80,80,false));
|
||||
ENCOUNTER_SPIDEY_1.x=79;
|
||||
ENCOUNTER_SPIDEY_1.y=47;
|
||||
ENCOUNTERS.push_back(ENCOUNTER_SPIDEY_1);
|
||||
|
||||
BASE_OBJECTS["DOME"]=new ObjectLoadInfo(DOME_DECAL);
|
||||
BASE_OBJECTS["PLANT"]=new ObjectLoadInfo(PLANT_DECAL);
|
||||
BASE_OBJECTS["EXIT"]=new ObjectLoadInfo(NULL);
|
||||
@ -497,6 +529,51 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (!IN_BATTLE_ENCOUNTER) {
|
||||
for (int i=0;i<ENCOUNTERS.size();i++) {
|
||||
Encounter enc = ENCOUNTERS.at(i);
|
||||
if (collidesWithPlayer(enc)) {
|
||||
IN_BATTLE_ENCOUNTER=true;
|
||||
CURRENT_ENCOUNTER=&enc;
|
||||
BATTLE_ENTRY_TIMER=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IN_BATTLE_ENCOUNTER) {
|
||||
BATTLE_ENTRY_TIMER++;
|
||||
if (BATTLE_ENTRY_TIMER>45) {
|
||||
int TARGET_COORDS_X=CURRENT_ENCOUNTER->x+WIDTH/32/2;
|
||||
int TARGET_COORDS_Y=CURRENT_ENCOUNTER->y+HEIGHT/32/2;
|
||||
if (PLAYER_COORDS[0]!=TARGET_COORDS_X) {
|
||||
if (PLAYER_COORDS[0]<TARGET_COORDS_X) {
|
||||
PLAYER_COORDS[0]+=BATTLE_CAMERA_SCROLL_SPD;
|
||||
if (PLAYER_COORDS[0]>TARGET_COORDS_X) {
|
||||
PLAYER_COORDS[0]=TARGET_COORDS_X;
|
||||
}
|
||||
} else {
|
||||
PLAYER_COORDS[0]-=BATTLE_CAMERA_SCROLL_SPD;
|
||||
if (PLAYER_COORDS[0]<TARGET_COORDS_X) {
|
||||
PLAYER_COORDS[0]=TARGET_COORDS_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PLAYER_COORDS[0]!=TARGET_COORDS_Y) {
|
||||
if (PLAYER_COORDS[1]<TARGET_COORDS_Y) {
|
||||
PLAYER_COORDS[1]+=BATTLE_CAMERA_SCROLL_SPD;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (CURRENT_CUTSCENE) {
|
||||
case CUTSCENE_4:{
|
||||
if (!messageBoxVisible) {
|
||||
@ -644,6 +721,9 @@ public:
|
||||
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);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case CUTSCENE_3:{
|
||||
@ -711,6 +791,11 @@ public:
|
||||
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));
|
||||
}
|
||||
}
|
||||
for (auto&enc:ENCOUNTERS) {
|
||||
for (auto&ent:enc.entities) {
|
||||
DrawDecal({(enc.x+ent.x-PLAYER_COORDS[0])*32+WIDTH/2,(enc.y+ent.y-PLAYER_COORDS[1])*32+HEIGHT/2},ent.spr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int getPlantId(int x, int y) {
|
||||
@ -840,6 +925,11 @@ public:
|
||||
PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+obj.spr->sprite->height/32.0;
|
||||
}
|
||||
}
|
||||
|
||||
bool collidesWithPlayer(Encounter obj) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Binary file not shown.
BIN
assets/spidey.png
Normal file
BIN
assets/spidey.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 920 B |
Loading…
x
Reference in New Issue
Block a user