Lose when hitting neggs

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 3 years ago
parent adf6323404
commit cc9bb002c1
  1. BIN
      MeercaChase
  2. 26
      MeercaChase.cpp
  3. BIN
      MeercaChase.wasm
  4. BIN
      assets/badnegg.png

Binary file not shown.

@ -7,17 +7,16 @@ using namespace std;
class MeercaChase : public olc::PixelGameEngine class MeercaChase : public olc::PixelGameEngine
{ {
public: public:
olc::Decal*meerca; olc::Decal*meerca,*negg,*badnegg;
olc::Decal*negg;
const float UPDATE_RATE = 0.016666667f; const float UPDATE_RATE = 0.016666667f;
const int NEGG_BOUNDARY=16; const int NEGG_BOUNDARY=16;
float accumulatedTime = 0.0f; float accumulatedTime = 0.0f;
int frameCount=0; int frameCount=0;
int moveSpd=4; int moveSpd=4;
float meercaSpd[2] = {0,0}; float meercaSpd[2] = {0,0};
float meercaPos[2] = {0,0}; float meercaPos[2] = {240,240};
float neggPos[2] = {}; float neggPos[2] = {};
float*badNeggs; float*badNeggs=NULL;
int badNeggCount=0; int badNeggCount=0;
void assignNeggRandomPos() { void assignNeggRandomPos() {
@ -32,17 +31,27 @@ public:
MeercaChase() MeercaChase()
{ {
sAppName = "Meerca Chase"; sAppName = "Meerca Chase";
init();
}
void init() {
srand(432189); srand(432189);
assignNeggRandomPos(); assignNeggRandomPos();
if (badNeggs!=NULL) {
free(badNeggs);
}
badNeggs=(float*)malloc(sizeof(float)*0); badNeggs=(float*)malloc(sizeof(float)*0);
badNeggCount=0;
meercaPos[0]=240;
meercaPos[1]=240;
} }
bool OnUserCreate() override bool OnUserCreate() override
{ {
meerca = new olc::Decal(new olc::Sprite("assets/meerca.png")); meerca = new olc::Decal(new olc::Sprite("assets/meerca.png"));
negg = new olc::Decal(new olc::Sprite("assets/negg.png")); negg = new olc::Decal(new olc::Sprite("assets/negg.png"));
badnegg = new olc::Decal(new olc::Sprite("assets/badnegg.png"));
SetPixelMode(olc::Pixel::ALPHA); SetPixelMode(olc::Pixel::ALPHA);
ConsoleCaptureStdOut(true); ConsoleCaptureStdOut(true);
Clear(olc::DARK_GREY); Clear(olc::DARK_CYAN);
// Called once at the start, so create things here // Called once at the start, so create things here
return true; return true;
@ -88,7 +97,7 @@ public:
} }
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW); DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW);
for (int i=0;i<badNeggCount;i++) { for (int i=0;i<badNeggCount;i++) {
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},negg,0,{16,16},{1,1},olc::DARK_GREY); DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},badnegg,0,{16,16},{1,1});
} }
return true; return true;
} }
@ -103,6 +112,11 @@ public:
spawnBadNegg(); spawnBadNegg();
} }
} }
for (int i=0;i<badNeggCount;i++) {
if (abs(meercaPos[0]-badNeggs[i*2])<6&&abs(meercaPos[1]-badNeggs[i*2+1])<6) {
init();
}
}
} }
}; };

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Loading…
Cancel
Save