generated from sigonasr2/CPlusPlusProjectTemplate
Tail graphics corner bug removed along with resetting score on reset
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
5d2458b576
commit
7f041fb757
BIN
MeercaChase
BIN
MeercaChase
Binary file not shown.
@ -40,6 +40,8 @@ public:
|
||||
float*badNeggs=NULL;
|
||||
int badNeggCount=0;
|
||||
int tailSize=0;
|
||||
int score=0;
|
||||
boolean justTouched=false;
|
||||
|
||||
void assignNeggRandomPos() {
|
||||
do {
|
||||
@ -87,6 +89,7 @@ public:
|
||||
meercaPreviousPos=(float*)malloc(sizeof(float)*0);
|
||||
badNeggCount=0;
|
||||
tailSize=0;
|
||||
score=0;
|
||||
meercaPos[0]=240;
|
||||
meercaPos[1]=240;
|
||||
meercaSpd[0]=0;
|
||||
@ -148,16 +151,12 @@ public:
|
||||
for (int i=0;i<badNeggCount;i++) {
|
||||
DrawRotatedDecal({badNeggs[i*2],badNeggs[i*2+1]},badnegg,0,{16,16},{1,1});
|
||||
}
|
||||
if (tailSize>=1) {
|
||||
DrawString({16,16},to_string(meercaPreviousPos[3])+" "+to_string(meercaPreviousPos[2])+" "+to_string(meercaPreviousPos[1])+" "+to_string(meercaPreviousPos[0]));
|
||||
}
|
||||
DrawString({16,16},"Score: "+to_string(score),olc::VERY_DARK_BLUE);
|
||||
for (int i=0;i<tailSize;i++) {
|
||||
if (meercaPreviousPos[(i*8+6)]!=0||meercaPreviousPos[(i*8+7)]!=0) {
|
||||
if (abs(meercaPos[0]-meercaPreviousPos[(i*8+6)])<8&&abs(meercaPos[1]-meercaPreviousPos[(i*8+7)])<8) {
|
||||
init();
|
||||
}
|
||||
DrawCircle({(float)meercaPreviousPos[(i*8+6)],(float)meercaPreviousPos[(i*8+7)]},8);
|
||||
if (i!=tailSize-1&&abs(meercaPos[0]-meercaPreviousPos[(i*8+6)])<8&&abs(meercaPos[1]-meercaPreviousPos[(i*8+7)])<8) {
|
||||
init();
|
||||
}
|
||||
DrawCircle({(float)meercaPreviousPos[(i*8+6)],(float)meercaPreviousPos[(i*8+7)]},8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -178,7 +177,13 @@ public:
|
||||
if (abs(meercaPos[0]-neggPos[0])<8&&abs(meercaPos[1]-neggPos[1])<8) {
|
||||
assignNeggRandomPos();
|
||||
tailSize++;
|
||||
score++;
|
||||
justTouched=true;
|
||||
meercaPreviousPos=(float*)realloc(meercaPreviousPos,sizeof(float)*tailSize*8);
|
||||
for (int i=0;i<8;i+=2) {
|
||||
meercaPreviousPos[(tailSize-1)*8+i]=meercaPos[0];
|
||||
meercaPreviousPos[(tailSize-1)*8+i+1]=meercaPos[1];
|
||||
}
|
||||
if ((float)rand()/(float)RAND_MAX<0.6) {
|
||||
spawnBadNegg();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user