generated from sigonasr2/CPlusPlusProjectTemplate
Bad neggs spawn
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
431e7d89ca
commit
adf6323404
BIN
MeercaChase
BIN
MeercaChase
Binary file not shown.
@ -17,16 +17,24 @@ public:
|
|||||||
float meercaSpd[2] = {0,0};
|
float meercaSpd[2] = {0,0};
|
||||||
float meercaPos[2] = {0,0};
|
float meercaPos[2] = {0,0};
|
||||||
float neggPos[2] = {};
|
float neggPos[2] = {};
|
||||||
|
float*badNeggs;
|
||||||
|
int badNeggCount=0;
|
||||||
|
|
||||||
void assignNeggRandomPos() {
|
void assignNeggRandomPos() {
|
||||||
neggPos[0]=(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()/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()
|
MeercaChase()
|
||||||
{
|
{
|
||||||
sAppName = "Meerca Chase";
|
sAppName = "Meerca Chase";
|
||||||
srand(432189);
|
srand(432189);
|
||||||
assignNeggRandomPos();
|
assignNeggRandomPos();
|
||||||
|
badNeggs=(float*)malloc(sizeof(float)*0);
|
||||||
}
|
}
|
||||||
bool OnUserCreate() override
|
bool OnUserCreate() override
|
||||||
{
|
{
|
||||||
@ -79,6 +87,9 @@ public:
|
|||||||
DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,0,{16,16});
|
DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,0,{16,16});
|
||||||
}
|
}
|
||||||
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++) {
|
||||||
|
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},negg,0,{16,16},{1,1},olc::DARK_GREY);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,6 +99,9 @@ public:
|
|||||||
|
|
||||||
if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) {
|
if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) {
|
||||||
assignNeggRandomPos();
|
assignNeggRandomPos();
|
||||||
|
if ((float)rand()/(float)RAND_MAX<0.6) {
|
||||||
|
spawnBadNegg();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
BIN
MeercaChase.wasm
BIN
MeercaChase.wasm
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user