void Ultra::play() { float volume = 0.0; FMOD_Channel_SetVolume(musicChannel, 1.0); FMOD_Channel_GetVolume(musicChannel, &volume); fout << volume << std::endl; playMusic(ultraMusic); setCurrentGamePiece(createNewPiece()); setNextPiece(createNewPiece()); enableCurrentPiece(); setLinesCompleted(0); setLevel(1); setFallIterationDelay(computeFallIterationDelay()); setScore(0); setState(RUNNING); sf::Clock fallingClock; fallingClock.Reset(); float currentTime = 0, precTime = 0; while(renderArea->IsOpened()) { if(getState() == PAUSED) { setBackground(PAUSE_IMG); timer.pause(); if(handlePauseInput() == RETURN_MAIN) return; } else { timer.start(); currentTime = fallingClock.GetElapsedTime(); handleTimerInput(currentTime, precTime); handleUserInput(); if(Game::gameOver() || timeElapsed()) { if(handleGameOverInput() == RETURN_MAIN) return; } else render(); } renderArea->Display(); } }
void Sprint::play() { playMusic(sprintMusic); setCurrentGamePiece(createNewPiece()); setNextPiece(createNewPiece()); enableCurrentPiece(); setLinesCompleted(0); setLevel(1); setFallIterationDelay(computeFallIterationDelay()); setScore(0); setState(RUNNING); sf::Clock fallingClock; fallingClock.Reset(); float currentTime = 0, precTime = 0; while(renderArea->IsOpened()) { setNbLinesToDelete(NB_LINES_TO_DELETE - getLinesCompleted()); if(getState() == PAUSED) { timer.pause(); if(handlePauseInput() == RETURN_MAIN) return; } else { timer.start(); currentTime = fallingClock.GetElapsedTime(); handleTimerInput(currentTime, precTime); handleUserInput(); if(Game::gameOver() || finished()) { timer.pause(); if(handleGameOverInput() == RETURN_MAIN) return; } else render(); } renderArea->Display(); } }
void Game::play() { playMusic(marathonMusic); setCurrentGamePiece(createNewPiece()); setNextPiece(createNewPiece()); enableCurrentPiece(); setLinesCompleted(0); setLevel(1); setFallIterationDelay(computeFallIterationDelay()); setScore(0); setState(RUNNING); sf::Clock fallingClock; fallingClock.Reset(); float currentTime = 0, precTime = 0; while(renderArea->IsOpened()) { if(getState() == PAUSED) { if(handlePauseInput() == RETURN_MAIN) return; } else { currentTime = fallingClock.GetElapsedTime(); handleTimerInput(currentTime, precTime); handleUserInput(); if(!gameOver()) render(BG_IMG); else { if(handleGameOverInput() == RETURN_MAIN) return; } } renderArea->Display(); } }
void Game::restart() { continueMusic(); firstTimeHolding = true; shuffleRandomBag(); currentPieceIndex = 0; gameArea.clear(); setLinesCompleted(0); setLevel(1); setScore(0); setFallIterationDelay(computeFallIterationDelay()); setState(RUNNING); setCurrentGamePiece(createNewPiece()); setNextPiece(createNewPiece()); enableCurrentPiece(); }
void Game::handlePieceLandAction() { if(!gameOver()) { gameArea.moveCurrentPieceDown(); setCurrentGamePiece(getNextPiece()); enableCurrentPiece(); setNextPiece(createNewPiece()); int n = gameArea.deletePossibleLines(); if(n != 0) playSound(deletion); updateGameInfos(n); } }
int getPossibleMoves(board Game, Piece piece, Move *movesTable, Point point) { int n = 0; movesTable[n] = newMove(); n++; if (piece->lastMove == currentTurn(Game)) { return n; } n = getMovesCommands(Game, piece, movesTable, point); Move result = moveBuilder(point, piece, Game); int board_Size = boardSize(Game); int x = point->x; int y = point->y; if (toupper(piece->letter) == 'C' && currentTurn(Game) - piece->lastMove >=3 ) { for (int j=-1; j<=1; j++) { for (int i=-1; i<=1; i++) { if ( (j != 0 || i != 0) && validatePoint(makePoint(x + i, y + j), board_Size) && isPositionFree(Game, x + i, y + j)) { result->xTo = x + i; result->yTo = y + j; result->isPieceRemoved= NULL; char letter = piece->letter; Piece pieceCreated = createNewPiece(piece->owner, letter, currentTurn(Game)); result->isPieceCreated = pieceCreated; result->command = PRODUCE_PEASANT; movesTable[n] = newMove(); copyMoveData(movesTable[n], result); n++; free(result->isPieceCreated); letter = matchingKnightLetter(letter); pieceCreated = createNewPiece(piece->owner, letter, currentTurn(Game) - 1); result->isPieceCreated = pieceCreated; result->command = PRODUCE_KNIGHT; movesTable[n] = newMove(); copyMoveData(movesTable[n], result); n++; free(result->isPieceCreated); } } } } free(result); return n; }