|
|
|
@ -23,18 +23,32 @@ struct TailData{ |
|
|
|
|
int waitTime = 0; |
|
|
|
|
char futureIndex=0; |
|
|
|
|
}; |
|
|
|
|
//Yellow = 1
|
|
|
|
|
//Blue = 2
|
|
|
|
|
//Green = 3
|
|
|
|
|
//Grey = 4
|
|
|
|
|
//Brown = 5
|
|
|
|
|
//Aqua = 6
|
|
|
|
|
//Red = 7
|
|
|
|
|
//Orange = 8
|
|
|
|
|
//Golden = 9
|
|
|
|
|
//Rainbow = 10
|
|
|
|
|
|
|
|
|
|
class MeercaChase : public olc::PixelGameEngine |
|
|
|
|
{ |
|
|
|
|
public: |
|
|
|
|
olc::Decal*meerca,*negg,*badnegg; |
|
|
|
|
olc::Decal*meerca,*negg,*badnegg,*goldennegg,*rainbownegg; |
|
|
|
|
const float UPDATE_RATE = 0.016666667f; |
|
|
|
|
const int NEGG_BOUNDARY=6; |
|
|
|
|
float accumulatedTime = 0.0f; |
|
|
|
|
int frameCount=0; |
|
|
|
|
int moveSpd=4; |
|
|
|
|
int neggType=1; |
|
|
|
|
float meercaSpd[2] = {0,0}; |
|
|
|
|
float meercaPos[2] = {240,240}; |
|
|
|
|
float scorePos[2] = {-50,-50}; |
|
|
|
|
int scoreTransparency=255; |
|
|
|
|
int scoreValue=1; |
|
|
|
|
float*meercaPreviousPos=NULL; |
|
|
|
|
float neggPos[2] = {}; |
|
|
|
|
float*badNeggs=NULL; |
|
|
|
@ -100,6 +114,8 @@ public: |
|
|
|
|
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")); |
|
|
|
|
goldennegg = new olc::Decal(new olc::Sprite("assets/golden_negg.png")); |
|
|
|
|
rainbownegg = new olc::Decal(new olc::Sprite("assets/rainbow_negg.png")); |
|
|
|
|
SetPixelMode(olc::Pixel::ALPHA); |
|
|
|
|
ConsoleCaptureStdOut(true); |
|
|
|
|
Clear(olc::DARK_CYAN); |
|
|
|
@ -147,7 +163,38 @@ public: |
|
|
|
|
} else { |
|
|
|
|
DrawRotatedDecal({meercaPos[0],meercaPos[1]},meerca,0,{16,16}); |
|
|
|
|
} |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW); |
|
|
|
|
switch (neggType) { |
|
|
|
|
case 1:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::YELLOW); |
|
|
|
|
}break; |
|
|
|
|
case 2:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::BLUE); |
|
|
|
|
}break; |
|
|
|
|
case 3:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::GREEN); |
|
|
|
|
}break; |
|
|
|
|
case 4:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::GREY); |
|
|
|
|
}break; |
|
|
|
|
case 5:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(71,36,20)); |
|
|
|
|
}break; |
|
|
|
|
case 6:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(0,251,255)); |
|
|
|
|
}break; |
|
|
|
|
case 7:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::RED); |
|
|
|
|
}break; |
|
|
|
|
case 8:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},negg,0,{16,16},{1.5,1.5},olc::Pixel(255,128,0)); |
|
|
|
|
}break; |
|
|
|
|
case 9:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},goldennegg,0,{16,16},{1.5,1.5},olc::WHITE); |
|
|
|
|
}break; |
|
|
|
|
case 10:{ |
|
|
|
|
DrawRotatedDecal({neggPos[0],neggPos[1]},rainbownegg,0,{16,16},{1.5,1.5},olc::WHITE); |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<badNeggCount;i++) { |
|
|
|
|
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},badnegg,0,{16,16},{1,1}); |
|
|
|
|
} |
|
|
|
@ -177,8 +224,12 @@ public: |
|
|
|
|
if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) { |
|
|
|
|
assignNeggRandomPos(); |
|
|
|
|
tailSize++; |
|
|
|
|
score++; |
|
|
|
|
score+=neggType; |
|
|
|
|
justTouched=true; |
|
|
|
|
neggType=1; |
|
|
|
|
while (rand()%2==0&&neggType<10) { |
|
|
|
|
neggType++; |
|
|
|
|
} |
|
|
|
|
meercaPreviousPos=(float*)realloc(meercaPreviousPos,sizeof(float)*tailSize*8); |
|
|
|
|
for (int i=0;i<8;i+=2) { |
|
|
|
|
meercaPreviousPos[(tailSize-1)*8+i]=meercaPos[0]; |
|
|
|
|