Question: I am trying to get my code If the ball touches the bottom of the window, pause the ball and print the following text to
I am trying to get my code If the ball touches the bottom of the window, pause the ball and print the following text to the middle of the screen. You lose. Press R to play again. I put in the code but is is not working can you help me fix it#include "stdafx.h
#include "Game.h
Game::Game
forint i ; i;i
Box brick;
brick.width ;
brick.height ;
brick.xposition ibrickwidth;
brick.yposition ;
brick.doubleThick true;
brick.color ConsoleColor::DarkGreen;
bricks.pushbackbrick;
Reset;
void Game::Reset
Console::SetWindowSizeWINDOWWIDTH, WINDOWHEIGHT;
Console::CursorVisiblefalse;
paddle.width ;
paddle.height ;
paddle.xposition ;
paddle.yposition ;
ball.visage O;
ball.color ConsoleColor::Cyan;
ResetBall;
TODO # Add this brick and more bricks to the vector
brick.width ;
brick.height ;
brick.xposition ;
brick.yposition ;
brick.doubleThick true;
brick.color ConsoleColor::DarkGreen;
void Game::ResetBall
ball.xposition paddle.xposition paddle.width ;
ball.yposition paddle.yposition ;
ball.xvelocity rand : ;
ball.yvelocity ;
ball.moving false;
bool Game::Update
if GetAsyncKeyStateVKESCAPE & x
return false;
if GetAsyncKeyStateVKRIGHT && paddle.xposition WINDOWWIDTH paddle.width
paddle.xposition ;
if GetAsyncKeyStateVKLEFT && paddle.xposition
paddle.xposition ;
if GetAsyncKeyStateVKSPACE & x
ball.moving ball.moving;
if GetAsyncKeyStateR & x
Reset;
ball.Update;
CheckCollision;
return true;
All rendering should be done between the locks in this function
void Game::Render const
Console::Locktrue;
Console::Clear;
paddle.Draw;
ball.Draw;
TODO # Update render to render all bricks
forconst auto&brick: bricks
brick.Draw;
Console::Lockfalse;
void Game::CheckCollision
TODO # Update collision to check all bricks
for auto it bricks.begin; it bricks.end;
if brickContainsballxposition ball.xvelocity, ball.yposition ball.yvelocity
brick.color ConsoleColorbrickcolor ;
ball.yvelocity ;
it bricks.eraseit;
TODO # If the ball hits the same brick times color black remove it from the vector
else
it;
TODO # If no bricks remain, pause ball and display victory text with R to reset
if paddleContainsballxposition ball.xvelocity, ball.yvelocity ball.yposition
ball.yvelocity ;
TODO # If ball touches bottom of window, pause ball and display defeat text with R to reset
if ballmoving WINDOWHEIGHT
std::cout "You lose.Press R to play again." std::endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
