generated from sigonasr2/CPlusPlusProjectTemplate
Node collecting works
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
b80675746a
commit
2bdfd3da27
@ -21,6 +21,14 @@ enum CUTSCENE{
|
||||
CUTSCENE_4,
|
||||
};
|
||||
|
||||
enum WEATHER_POWER{
|
||||
HAILSTORM,
|
||||
HURRICANE,
|
||||
METEOR_SHOWER,
|
||||
METEOR_STORM,
|
||||
SNOW_STORM
|
||||
};
|
||||
|
||||
#define WIDTH 256
|
||||
#define HEIGHT 224
|
||||
#define ALPHA_SCREEN1 128
|
||||
@ -140,6 +148,20 @@ public:
|
||||
Animation POWER_SNOWSTORM_ANIMATION;
|
||||
std::vector<Entity> entityList;
|
||||
bool IN_BATTLE_ENCOUNTER = false;
|
||||
int WEATHER_POWERS[15] = {
|
||||
3,
|
||||
1,
|
||||
5,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,0,0};
|
||||
|
||||
|
||||
olc::Decal*DOME_DECAL,*FOOD_METER_DECAL,*OXYGEN_METER_DECAL,*PLANT_DECAL,
|
||||
@ -405,8 +427,8 @@ public:
|
||||
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);
|
||||
ConsoleClear();
|
||||
cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
//ConsoleClear();
|
||||
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
if (!changed&&¤t_playerAnim!=&playerAnimWalkRight) {
|
||||
changeAnimation(playerAnimWalkRight);
|
||||
changed=true;
|
||||
@ -414,8 +436,8 @@ public:
|
||||
}
|
||||
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);
|
||||
ConsoleClear();
|
||||
cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
//ConsoleClear();
|
||||
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
if (!changed&&¤t_playerAnim!=&playerAnimWalkLeft) {
|
||||
changeAnimation(playerAnimWalkLeft);
|
||||
changed=true;
|
||||
@ -423,8 +445,8 @@ public:
|
||||
}
|
||||
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);
|
||||
ConsoleClear();
|
||||
cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
//ConsoleClear();
|
||||
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
if (!changed&&¤t_playerAnim!=&playerAnimWalkUp) {
|
||||
changeAnimation(playerAnimWalkUp);
|
||||
changed=true;
|
||||
@ -432,8 +454,8 @@ public:
|
||||
}
|
||||
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);
|
||||
ConsoleClear();
|
||||
cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
//ConsoleClear();
|
||||
//cout<<"("<<PLAYER_COORDS[0]<<","<<PLAYER_COORDS[1]<<+")";
|
||||
if (!changed&&¤t_playerAnim!=&playerAnimWalkDown) {
|
||||
changeAnimation(playerAnimWalkDown);
|
||||
changed=true;
|
||||
@ -441,6 +463,15 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<OBJECTS.size();i++) {
|
||||
Object obj = OBJECTS.at(i);
|
||||
if (obj.name.compare("HAILSTORM_NODE")==0&&collidesWithPlayer(obj)) {
|
||||
int amountGained=rand()%4+2;
|
||||
cout<<"Increased HAILSTORM power inventory count by "<<amountGained<<".\n";
|
||||
OBJECTS.erase(OBJECTS.begin()+i--);
|
||||
}
|
||||
}
|
||||
|
||||
switch (CURRENT_CUTSCENE) {
|
||||
case CUTSCENE_4:{
|
||||
if (!messageBoxVisible) {
|
||||
@ -774,6 +805,16 @@ public:
|
||||
current_playerAnim=anim;
|
||||
current_playerAnim.frame=0;
|
||||
}
|
||||
|
||||
bool collidesWithPlayer(Object obj) {
|
||||
if (obj.hasAnim) {
|
||||
return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+obj.anim->width&&
|
||||
PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+obj.anim->height;
|
||||
} else {
|
||||
return PLAYER_COORDS[0]>=obj.x&&PLAYER_COORDS[0]<=obj.x+obj.spr->sprite->width&&
|
||||
PLAYER_COORDS[1]>=obj.y&&PLAYER_COORDS[1]<=obj.y+obj.spr->sprite->height;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user