void Player::onCol(SpriteType st, Sprite *s, int dir) { SpriteEx *se = dynamic_cast<SpriteEx *>(s); switch (st) { case ST_ENEMY: case ST_ENEMY_BULLET: if (hitTimer == 0) { hit(se->getSubType(), se->getx() - x); } break; case ST_FLOOR: die(); break; case ST_TILE: // if going down, we landed if (dir == DIR_VERTICAL && dy > 0) { air = false; dy = 0; jumpTimer = 0; } break; case ST_BOUNDS: if (dir == DIR_HORIZONTAL && dx > 0) { winLevel(); } break; default: /* do nothing */ break; } }
/** * @brief level::currentLevelStatus * * Determines the status of the level/determines if the level has * been completed and won. */ void Game::currentLevelStatus() { currentQuestion++; if(currentQuestion > 5) { if(correctCount >= 3) { emit winLevel(correctCount); } else { emit loseLevel(correctCount); } currentQuestion = 0; correctCount = 0; } }
int main() { setupInterrupts(); setupSounds(); playSoundA(titleSong, TITLESONGLEN, TITLESONGFREQ, 1); // Start game with splash screen splash(); // Main Game Loop while (1) { oldButtons = buttons; buttons = BUTTONS; // Update player row and column player.bigRow = player.row + vOff; player.bigCol = player.col + hOff; switch(state) { case SPLASH: // Displays splash screen splash(); break; case INSTRUCTIONS: instructions(); break; case GAME: // Game Function holds all game logic game(); break; case SEASONCHANGE: // Warp-like animation as player changes between seasons warpAnimation(); // Change game to correct season, based on prevSeason and return to gameplay if (vBlankCount < 1) { seasonChange(); state = GAME; } break; case PAUSE: pause(); break; case LOSE: lose(); break; case WINLEVEL: winLevel(); break; case GAMEEND: gameEnd(); break; } // Shadow OAM Handling // Player Sprite shadowOAM[0].attr0 = (ROWMASK & player.row) | ATTR0_SQUARE; shadowOAM[0].attr1 = (COLMASK & player.col) | ATTR1_SIZE16 | (ATTR1_HFLIP & (player.facing << 12)); shadowOAM[0].attr2 = (SPRITEOFFSET16(season * 2, player.currentFrame * 2)) | ATTR2_PRIORITY2; // Season Icon Sprite shadowOAM[1].attr0 = (ROWMASK & icon.row) | ATTR0_SQUARE; shadowOAM[1].attr1 = (COLMASK & icon.col) | ATTR1_SIZE16; shadowOAM[1].attr2 = (SPRITEOFFSET16(season * 2, 6)) | (1 << 10); // Priority 1 REG_BG2HOFS = hOff; REG_BG2VOFS = vOff; // Set BG1 offsets - used for snow and falling leaves REG_BG1HOFS = bg1HOff; REG_BG1VOFS = bg1VOff; //Copy the shadowOAM into the OAM DMANow(3, &shadowOAM, OAM, 512); waitForVblank(); } return 0; }