I have this function with some if statement see below:
Code: Select all
int GameEvents(void){
int test = 0;
if (BlockStatus[3] == 0 || BlockStatus[4] == 0){
//sprintf(sBuffer, "Begin: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
//DebugOutput(sBuffer);
if (iQuadPosY == 11) {
sprintf(sBuffer, "ELF IS GEKOZEN");
DebugOutput(sBuffer);
// if no blocks are changed yet then the quad is in its whole on the bottom
if (BlockStatus[3] == 0 && BlockStatus[4] == 0) {
iField[iQuadPosX + 1][12] = iCurrentQuad[3];
BlockStatus[3] = 1;
iField[iQuadPosX + 1][11] = iCurrentQuad[2];
BlockStatus[2] = 1;
iField[iQuadPosX][12] = iCurrentQuad[4];
BlockStatus[4] = 1;
iField[iQuadPosX][11] = iCurrentQuad[1];
BlockStatus[1] = 1;
CheckSurroundingField(iQuadPosX + 1, 12, iCurrentQuad[3]);
CheckSurroundingField(iQuadPosX + 1, 11, iCurrentQuad[2]);
CheckSurroundingField(iQuadPosX, 12, iCurrentQuad[4]);
CheckSurroundingField(iQuadPosX, 11, iCurrentQuad[1]);
sprintf(sBuffer, "(11) BEIDE 0: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
// only the left part is on the bottom
else if (BlockStatus[4] == 0 && BlockStatus[3] == 1) {
iField[iQuadPosX][12] = iCurrentQuad[4];
BlockStatus[4] = 1;
iField[iQuadPosX][11] = iCurrentQuad[1];
BlockStatus[1] = 1;
CheckSurroundingField(iQuadPosX, 12, iCurrentQuad[4]);
CheckSurroundingField(iQuadPosX, 11, iCurrentQuad[1]);
sprintf(sBuffer, "(11) BLOK 4: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
// only the right part is on the bottom
else if (BlockStatus[4] == 1 && BlockStatus[3] == 0) {
iField[iQuadPosX + 1][12] = iCurrentQuad[3];
BlockStatus[3] = 1;
iField[iQuadPosX + 1][11] = iCurrentQuad[2];
BlockStatus[2] = 1;
CheckSurroundingField(iQuadPosX + 1, 12, iCurrentQuad[3]);
CheckSurroundingField(iQuadPosX + 1, 11, iCurrentQuad[2]);
sprintf(sBuffer, "(11) BLOK 3: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
iControllable = 1;
}
else {
//sprintf(sBuffer, "NIET ELF GEKOZEN: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
//DebugOutput(sBuffer);
if (iField[iQuadPosX + 1][iQuadPosY + 2] > 0 && iField[iQuadPosX][iQuadPosY + 2] > 0 && BlockStatus[3] == 0 && BlockStatus[4] == 0){
iField[iQuadPosX + 1][iQuadPosY + 1] = iCurrentQuad[3];
BlockStatus[3] = 1;
iField[iQuadPosX + 1][iQuadPosY] = iCurrentQuad[2];
BlockStatus[2] = 1;
iField[iQuadPosX][iQuadPosY + 1] = iCurrentQuad[4];
BlockStatus[4] = 1;
iField[iQuadPosX][iQuadPosY] = iCurrentQuad[1];
BlockStatus[1] = 1;
CheckSurroundingField(iQuadPosX + 1, iQuadPosY + 1, iCurrentQuad[3]);
CheckSurroundingField(iQuadPosX + 1, iQuadPosY, iCurrentQuad[2]);
CheckSurroundingField(iQuadPosX, iQuadPosY + 1, iCurrentQuad[4]);
CheckSurroundingField(iQuadPosX, iQuadPosY, iCurrentQuad[1]);
iControllable = 1;
sprintf(sBuffer, "(?) BEIDE 0: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
else if (iField[iQuadPosX + 1][iQuadPosY + 2] > 0 && iField[iQuadPosX][iQuadPosY + 2] == 0 && BlockStatus[3] == 0 && BlockStatus[4] == 0) {
iField[iQuadPosX + 1][iQuadPosY + 1] = iCurrentQuad[3];
BlockStatus[3] = 1;
iField[iQuadPosX + 1][iQuadPosY] = iCurrentQuad[2];
BlockStatus[2] = 1;
CheckSurroundingField(iQuadPosX + 1, iQuadPosY + 1, iCurrentQuad[3]);
CheckSurroundingField(iQuadPosX + 1, iQuadPosY, iCurrentQuad[2]);
iControllable = 1;
sprintf(sBuffer, "(?1) BLOK 3: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
test = 1;
}
else if (iField[iQuadPosX + 1][iQuadPosY + 2] == 0 && iField[iQuadPosX][iQuadPosY + 2] > 0 && BlockStatus[3] == 0 && BlockStatus[4] == 0) {
iField[iQuadPosX][iQuadPosY + 1] = iCurrentQuad[4];
BlockStatus[4] = 1;
iField[iQuadPosX][iQuadPosY] = iCurrentQuad[1];
BlockStatus[1] = 1;
CheckSurroundingField(iQuadPosX, iQuadPosY + 1, iCurrentQuad[4]);
CheckSurroundingField(iQuadPosX, iQuadPosY, iCurrentQuad[1]);
iControllable = 1;
sprintf(sBuffer, "(?1) BLOK 4: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
else if (iField[iQuadPosX][iQuadPosY + 2] > 0 && BlockStatus[3] == 1 && BlockStatus[4] == 0) {
iField[iQuadPosX][iQuadPosY + 1] = iCurrentQuad[4];
BlockStatus[4] = 1;
iField[iQuadPosX][iQuadPosY] = iCurrentQuad[1];
BlockStatus[1] = 1;
CheckSurroundingField(iQuadPosX, iQuadPosY + 1, iCurrentQuad[4]);
CheckSurroundingField(iQuadPosX, iQuadPosY, iCurrentQuad[1]);
iControllable = 1;
sprintf(sBuffer, "(?2) BLOK 4: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
else if (iField[iQuadPosX + 1][iQuadPosY + 2] > 0 && BlockStatus[3] == 0 && BlockStatus[4] == 1) {
iField[iQuadPosX + 1][iQuadPosY + 1] = iCurrentQuad[3];
BlockStatus[3] = 1;
iField[iQuadPosX + 1][iQuadPosY] = iCurrentQuad[2];
BlockStatus[2] = 1;
CheckSurroundingField(iQuadPosX + 1, iQuadPosY + 1, iCurrentQuad[3]);
CheckSurroundingField(iQuadPosX + 1, iQuadPosY, iCurrentQuad[2]);
iControllable = 1;
sprintf(sBuffer, "(?2) BLOK 3: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
else {}
if (test == 1) {
sprintf(sBuffer, "NO ELF2: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
if (iControllable == 0) {
if (iDropSpeed == 40){
iQuadPosY += 1;
iDropSpeed = 0;
}
else { iDropSpeed += 1;}
}
else {
if (iDropSpeed == 10){
iQuadPosY += 1;
iDropSpeed = 0;
}
else { iDropSpeed += 1;}
}
if (test == 1) {
sprintf(sBuffer, "DROP GEDAAN: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
}
}
else {
sprintf(sBuffer, "CHECK: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
if (BlockStatus[3] == 1) {
if (BlockStatus[2] == 1) {
if (BlockStatus[1] == 1) {
if (BlockStatus[4] == 1) {
sprintf(sBuffer, "CHECK OKAY: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
BlockStatus[1] = 0;
BlockStatus[2] = 0;
BlockStatus[3] = 0;
BlockStatus[4] = 0;
GameCreateQuad();
return 0;
}
}
}
}
}
if (test == 1) {
sprintf(sBuffer, "EINDE FUNCTIE: %i,%i,%i,%i", BlockStatus[1], BlockStatus[2], BlockStatus[3], BlockStatus[4]);
DebugOutput(sBuffer);
}
/*if (iMessageShow == 1){
if (iMessageDuration < 120) {
iMessageDuration += 1;
}
else { iMessageShow = 0; iMessageDuration = 0;}
}*/
return 0;
}
BlockStatus[4] is at this time 0, when this happens it goes to the if statement where the "NO ELF2" is passed to the debugfunction then suddenly BlockStatus[4] == 1 why is this?