generated from sigonasr2/CPlusPlusProjectTemplate
Lose when hitting neggs
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
adf6323404
commit
cc9bb002c1
BIN
MeercaChase
BIN
MeercaChase
Binary file not shown.
@ -7,17 +7,16 @@ using namespace std;
|
||||
class MeercaChase : public olc::PixelGameEngine
|
||||
{
|
||||
public:
|
||||
olc::Decal*meerca;
|
||||
olc::Decal*negg;
|
||||
olc::Decal*meerca,*negg,*badnegg;
|
||||
const float UPDATE_RATE = 0.016666667f;
|
||||
const int NEGG_BOUNDARY=16;
|
||||
float accumulatedTime = 0.0f;
|
||||
int frameCount=0;
|
||||
int moveSpd=4;
|
||||
float meercaSpd[2] = {0,0};
|
||||
float meercaPos[2] = {0,0};
|
||||
float meercaPos[2] = {240,240};
|
||||
float neggPos[2] = {};
|
||||
float*badNeggs;
|
||||
float*badNeggs=NULL;
|
||||
int badNeggCount=0;
|
||||
|
||||
void assignNeggRandomPos() {
|
||||
@ -32,17 +31,27 @@ public:
|
||||
MeercaChase()
|
||||
{
|
||||
sAppName = "Meerca Chase";
|
||||
init();
|
||||
}
|
||||
void init() {
|
||||
srand(432189);
|
||||
assignNeggRandomPos();
|
||||
if (badNeggs!=NULL) {
|
||||
free(badNeggs);
|
||||
}
|
||||
badNeggs=(float*)malloc(sizeof(float)*0);
|
||||
badNeggCount=0;
|
||||
meercaPos[0]=240;
|
||||
meercaPos[1]=240;
|
||||
}
|
||||
bool OnUserCreate() override
|
||||
{
|
||||
meerca = new olc::Decal(new olc::Sprite("assets/meerca.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);
|
||||
ConsoleCaptureStdOut(true);
|
||||
Clear(olc::DARK_GREY);
|
||||
Clear(olc::DARK_CYAN);
|
||||
|
||||
// Called once at the start, so create things here
|
||||
return true;
|
||||
@ -88,7 +97,7 @@ public:
|
||||
}
|
||||
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);
|
||||
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},badnegg,0,{16,16},{1,1});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -103,6 +112,11 @@ public:
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
BIN
MeercaChase.wasm
BIN
MeercaChase.wasm
Binary file not shown.
BIN
assets/badnegg.png
Normal file
BIN
assets/badnegg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
Loading…
x
Reference in New Issue
Block a user