void SearchQueryView::playSound() { QString textName; int lineNumber; QList<Focus> foci; getDetails( currentIndex(), textName , lineNumber, foci ); emit requestPlaySound( textName, lineNumber ); }
//Move ball by the vel of its axis - and bounce or goal void moveBall(GameVars* gameVars) { //Move ball X gameVars->ball.xPos = gameVars->ball.xPos + gameVars->ball.xVel; //LEFT & RIGHT WALL if (gameVars->ball.xPos > ballRightMax) //Right wall { //Bounce wall sound requestPlaySound(GSoundWallBounce, gameVars); gameVars->ball.xPos = ballRightMax - 1; gameVars->ball.xVel = -(gameVars->ball.xVel); //bounce } else if(gameVars->ball.xPos < ballLeftMax) //Left wall { //Bounce wall sound requestPlaySound(GSoundWallBounce, gameVars); gameVars->ball.xPos = ballLeftMax + 1; gameVars->ball.xVel = -(gameVars->ball.xVel); //bounce } //Move ball Y gameVars->ball.yPos = gameVars->ball.yPos + gameVars->ball.yVel; //Speed-up movement handleBallSpeed(gameVars); //Scored? if (gameVars->ball.yPos < ballBottomMax) //Bottom wall { //GOAL playerScored(0, gameVars); } else if(gameVars->ball.yPos > ballTopMax) //Top wall { //GOAL playerScored(1, gameVars); } //HIT PLAYER 1 TOP SURFACE (up to 4 pixels deep) else if(gameVars->ball.yPos >= (player1YPos - paddleHeight) && gameVars->ball.yPos <= (player1YPos - paddleHeight + 4) && gameVars->ball.xPos <= (gameVars->player1.xPos + paddleWidth) && gameVars->ball.xPos >= (gameVars->player1.xPos - paddleWidth)) { //Bounce paddle sound requestPlaySound(GSoundPaddleBounce, gameVars); //Bounce off player 1 gameVars->ball.yPos = player1YPos - paddleHeight; gameVars->ball.yVel = -(gameVars->ball.yVel); //bounce //Angle change? checkIfBallEdged(&gameVars->player1, &gameVars->ball); //Speed up on Y velocity checkForSpeedUp(gameVars); } //HIT PLAYER 2 TOP SURFACE (up to 4 pixels deep) else if(gameVars->ball.yPos <= (player2YPos + paddleHeight) && gameVars->ball.yPos >= (player2YPos + paddleHeight - 4) && gameVars->ball.xPos <= (gameVars->player2.xPos + paddleWidth) && gameVars->ball.xPos >= (gameVars->player2.xPos - paddleWidth)) { //Bounce paddle sound requestPlaySound(GSoundPaddleBounce, gameVars); //Bounce off player 2 gameVars->ball.yPos = player2YPos + paddleHeight + 1; gameVars->ball.yVel = -(gameVars->ball.yVel); //bounce //Angle change? checkIfBallEdged(&gameVars->player2, &gameVars->ball); //Speed up on Y velocity checkForSpeedUp(gameVars); } }