Bad neggs spawn

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 3 years ago
parent 431e7d89ca
commit adf6323404
  1. BIN
      MeercaChase
  2. 18
      MeercaChase.cpp
  3. BIN
      MeercaChase.wasm

Binary file not shown.

@ -17,16 +17,24 @@ public:
float meercaSpd[2] = {0,0};
float meercaPos[2] = {0,0};
float neggPos[2] = {};
float*badNeggs;
int badNeggCount=0;
void assignNeggRandomPos() {
neggPos[0]=(float)rand()/RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
neggPos[1]=(float)rand()/RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
neggPos[0]=(float)rand()/(float)RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
neggPos[1]=(float)rand()/(float)RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
}
void spawnBadNegg() {
badNeggs=(float*)realloc(badNeggs,sizeof(float)*(++badNeggCount*2));
badNeggs[badNeggCount*2-2]=(float)rand()/(float)RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
badNeggs[badNeggCount*2-1]=(float)rand()/(float)RAND_MAX*(480-NEGG_BOUNDARY*2)+NEGG_BOUNDARY;
}
MeercaChase()
{
sAppName = "Meerca Chase";
srand(432189);
assignNeggRandomPos();
badNeggs=(float*)malloc(sizeof(float)*0);
}
bool OnUserCreate() override
{
@ -79,6 +87,9 @@ public:
DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,0,{16,16});
}
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW);
for (int i=0;i<badNeggCount;i++) {
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},negg,0,{16,16},{1,1},olc::DARK_GREY);
}
return true;
}
@ -88,6 +99,9 @@ public:
if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) {
assignNeggRandomPos();
if ((float)rand()/(float)RAND_MAX<0.6) {
spawnBadNegg();
}
}
}
};

Binary file not shown.
Loading…
Cancel
Save