Fundamental Breakout game(brick breaker) using C++

It is a fundamental C++ based project that requires a simple breakout (brick breaker) game coded using the requirements provided in the problem statement pdf attached. Use of pointers is not allowed. Also use of goto, break, or continue statements is not allowed. 3rd point in Project statement pdf says that any graphics library can be used. But you need to use no graphics file apart from the resource files and header files provided in the zipped file attached. That means any c++ inbuilt function can be used but no graphics library or file other than the one that has been provided.

Get Help With a similar task to - Fundamental Breakout game(brick breaker) using C++

Login to view and/or buy answers.. or post an answer
Additional Instructions:

Programming Fundamentals Project/myconsole.cpp Programming Fundamentals Project/myconsole.cpp #include <windows.h>  #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <conio.h> using namespace std; #include "myconsole.h" #include "mygraphics.h" //this function outputs a string str at position (x,y) of the screen  void OutputString(int x,int y,char *str) {         COORD c;     c.X = x;     c.Y = y;     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     SetConsoleCursorPosition(h,c);     cout << str;     cout.flush(); } //this function will clear the screen void ClearScreen() {     CONSOLE_SCREEN_BUFFER_INFO info;     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     GetConsoleScreenBufferInfo(h,&info);     system("cls");     SetConsoleCursorPosition(h,info.dwCursorPosition);      } //alternative to ClearScreen for Windows7 platform /*void ClearScreen1() {     PlaceCursor(0,0);     cout << string(10000, ' ');     cout.flush();     PlaceCursor(0,0); }*/ //this function will place the cursor at a certain position on the screen void PlaceCursor(int x,int y) {     COORD c;     c.X = x;     c.Y = y;     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     SetConsoleCursorPosition(h,c); } //this function checks if a key is pressed and if a key is pressed //then it returns the ascii code of the key pressed //the parameter waitTime specifies how long we have to wait for an input //the default value is 20 millisecond.  If within the wait time no key is pressed //the function returns zero. int CheckKeyPressed(int waitTime) {     HANDLE h= GetStdHandle(STD_INPUT_HANDLE);     INPUT_RECORD r;     DWORD w = 1;     DWORD eventss;     DWORD waitResult=0;     int keypressed = false;     int toReturn = 0;     waitResult = WaitForSingleObject(h,waitTime);     if (waitResult == WAIT_OBJECT_0)     {         //FlushConsoleInputBuffer(h);..commented out as this takes to asynchronous mode on some systems         keypressed = ReadConsoleInput(h,&r,1,&eventss);                  if (keypressed && r.EventType==KEY_EVENT && r.Event.KeyEvent.bKeyDown)             toReturn = r.Event.KeyEvent.wVirtualKeyCode;         //this should make sure that checkKeyPressed is not called twice for arrow keys         if (toReturn == 224)             toReturn = CheckKeyPressed(waitTime);                  FlushConsoleInputBuffer(h);     }     return toReturn; } //check if a key is pressed uing kbhit of conio.h //readconsoleinput does not work properly on some systems. int CheckKeyPressed1() {     int a=0; //  if (kbhit())     {   a = _getch();         if (a==224)    //arrow key             return CheckKeyPressed1();     }     return a; } void GetMaxWindowSize(int &maxHorizontal,int &maxVertical) {     COORD c; //    c.X = x; //    c.Y = y;          HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     c = GetLargestConsoleWindowSize(h); } //set the title of the window void GetMaxWindowCoordinates(int &x,int &y) {     CONSOLE_SCREEN_BUFFER_INFO info;     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     GetConsoleScreenBufferInfo(h,&info);     x = info.srWindow.Right;     y = info.srWindow.Bottom; } //won't set for more than a certain height and certain width, depending //upon your system void SetWindowSize(int width,int height) {     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);     bool bAbs = true;     SMALL_RECT r;     r.Left = 0;     r.Top  = 0;     r.Right = width;     r.Bottom = height;     SetConsoleWindowInfo(h,bAbs,&r); } //changes the color of a certain co-ordinate //color can be BACKGROUND_GREEN, BACKGROUND_BLUE,BACKGROUND_RED or a combination of these using | operator bool SetColorAtPoint(int x,int y,int color) {     COORD c,size;     c.X = x;     c.Y = y;     size.X = 1;     size.Y = 1;     HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);          WORD w = color;     unsigned long written = 0;     WriteConsoleOutputAttribute(h,&w,1,c,&written);     if (written)         return true;     return false; } #include<cmath> void Circle(int a, int b, int radius, COLORREF colVal) {     float x, y, change = 0;     x = a-radius;     for (;x <= radius + a;x+=0.005)     {         y = b+sqrt((radius*radius)-((x*x)+(a*a)-(2*a*x)));         change = y - b;         mySetPixel(x, b - change, colVal);         mySetPixel(x, y, colVal);     } } Programming Fundamentals Project/myconsole.h #ifndef MYCONSOLE_H #define MYCONSOLE_H #include<Windows.h> const int UPKEY = 38; const int DOWNKEY = 40; const int RIGHTKEY = 39; const int LEFTKEY = 37; const int ESCKEY = 27; //this function will place the cursor at a certain position on the screen void PlaceCursor(int x,int y); //this function will clear the screen void ClearScreen(); //this function outputs a string str at position (x,y) of the screen void OutputString(int x,int y,char *str); //this function is an alternative to ClearScreen(), when ClearScreen() does not work on windows 7 void ClearScreen1(); //this function checks if a key is pressed and if a key is pressed //then it returns the ascii code of the key pressed //the parameter waitTime specifies how long we have to wait for an input //the default value is 20 millisecond. If within the wait time no key is pressed //the function returns zero. int CheckKeyPressed(int waitTime = 20); //this function checks if a key is pressed and if a key is pressed //then it returns the ascii code of the key pressed //there is no wait time like in the above CheckKeyPressed function //you can use it if CheckKeyPressed gives you problems int CheckKeyPressed1(); //this will change the window size to width and height as specified in the function //will not work for greater than a certain width and greater than a certain height //depeding upon the system you are using void SetWindowSize(int width,int height); //changes the color of a certain co-ordinate //changes the color of a certain co-ordinate //color can be BACKGROUND_GREEN, BACKGROUND_BLUE,BACKGROUND_RED or a combination of these using | operator //e.g. you can send as parameter BACKGROUND_GREEN|BACKGROUND_BLUE //the following combinations are possible: //FOREGROUND_BLUE Text color contains blue. //FOREGROUND_GREEN Text color contains green. //FOREGROUND_RED Text color contains red. //FOREGROUND_INTENSITY Text color is intensified. //BACKGROUND_BLUE Background color contains blue. //BACKGROUND_GREEN Background color contains green. //BACKGROUND_RED Background color contains red. //BACKGROUND_INTENSITY Background color is intensified. //An example of usage: // PlaceCursor(0,0); // cout << '*'; // SetColorAtPoint(0,0,BACKGROUND_RED|FOREGROUND_BLUE); bool SetColorAtPoint(int x,int y,int color); //will get the maximum and minimum x and y coordinates of the current window void GetMaxWindowCoordinates(int &x,int &y); //will print a circle void Circle(int a, int b, int radius, COLORREF colVal); void GetMaxWindowSize(int &maxHorizontal, int &maxVertical); #endif Programming Fundamentals Project/mygraphics.cpp Programming Fundamentals Project/mygraphics.cpp #define _WIN32_WINNT 0x0500 #include <windows.h> #include <iostream> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <conio.h> void myLine(int x1, int y1, int x2, int y2,COLORREF lineColor) {     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     //change the color by changing the values in RGB (from 0-255)     HPEN pen =CreatePen(PS_SOLID,2,lineColor); //2 is the width of the pen     SelectObject(device_context,pen);     MoveToEx(device_context,x1,y1,NULL);     LineTo(device_context,x2, y2);     DeleteObject(pen);     ReleaseDC(console_handle, device_context); } void myRect(int x1, int y1, int x2, int y2,COLORREF lineColor,COLORREF fillColor) {     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     //change the color by changing the values in RGB (from 0-255)     HPEN pen =CreatePen(PS_SOLID,2,lineColor);     SelectObject(device_context,pen);     HBRUSH brush = ::CreateSolidBrush(fillColor);     SelectObject(device_context,brush);     Rectangle(device_context,x1,y1,x2,y2);     DeleteObject(pen);     DeleteObject(brush);     ReleaseDC(console_handle, device_context); } void myEllipse(int x1, int y1, int x2, int y2,COLORREF lineColor,COLORREF fillColor) {     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     //change the color by changing the values in RGB (from 0-255)     HPEN pen =CreatePen(PS_SOLID,2,lineColor);     SelectObject(device_context,pen);     HBRUSH brush = ::CreateSolidBrush(fillColor);     SelectObject(device_context,brush);     Ellipse(device_context,x1,y1,x2,y2);     DeleteObject(pen);     DeleteObject(brush);     ReleaseDC(console_handle, device_context); } void myDrawText(int x,int y,int ht,char str[],COLORREF lineColor,COLORREF fillColor) {     WCHAR wstr[20]={};     for (int i=0;i<20&&str[i];++i)         wstr[i] = str[i];     RECT rects;     rects.left = x;     rects.top = y;     rects.right = x+ht;     rects.bottom = y+ht;//(x,y,x+ht,y+ht);     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     SetTextColor(device_context,lineColor);     SetBkColor(device_context,fillColor);     DrawText(device_context, wstr,-1,&rects,DT_TOP|DT_NOCLIP);     ReleaseDC(console_handle, device_context); } void myDrawTextWithFont(int x,int y,int ht,char str[],COLORREF lineColor,COLORREF fillColor) {     WCHAR wstr[20]={};     for (int i=0;i<20&&str[i];++i)         wstr[i] = str[i];     RECT rects;     HFONT hFont;     rects.left = x;     rects.top = y;     rects.right = x+ht;     rects.bottom = y+ht;//(x,y,x+ht,y+ht);     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     hFont = CreateFont(ht,0,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_OUTLINE_PRECIS,                         CLIP_DEFAULT_PRECIS,1, VARIABLE_PITCH,TEXT("Impact"));     SelectObject(device_context, hFont);     SetTextColor(device_context,lineColor);     SetBkColor(device_context,fillColor);     DrawText(device_context, wstr,-1,&rects,DT_TOP|DT_NOCLIP);     DeleteObject(hFont);     ReleaseDC(console_handle, device_context); } void mySetPixel(float x,float y,COLORREF colorVal) {     HWND console_handle = GetConsoleWindow();     HDC device_context = GetDC(console_handle);     SetPixel(device_context,x,y,colorVal);     ReleaseDC(console_handle,device_context); } Programming Fundamentals Project/mygraphics.h #ifndef MYGRAPHICS_H #define MYGRAPHICS_H #include <windows.h> //To compile your program with graphics.cpp you need to include the gdi32 library //compile it using: g++ -o myprog.exe myprog.cpp graphics.cpp -lgdi32 //set the color of a pixel at (x,y) to colorVal //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage exammple: mySetPixel(200,200,RGB(230,0,0)); void mySetPixel(float x,float y,COLORREF colorVal); //draw a line from (x1,y1) to (x2,y2) using lineColor //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage example: myLine(0,0,300,400,COLORREF(200,0,0)); void myLine(int x1, int y1, int x2, int y2,COLORREF lineColor); //draw a rectangle with top corner (x1,y1) and bottom corner(x2,y2) with outline lineColor //and fillColor //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage example: myRect(300,300,350,350,RGB(100,0,0),RGB(0,0,240)); void myRect(int x1, int y1, int x2, int y2,COLORREF lineColor,COLORREF fillColor); //draw an ellipse within a rectangle with top corner (x1,y1) and bottom corner(x2,y2) //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage example: myEllipse(100,50,180,200,RGB(100,0,0),RGB(0,0,240)); void myEllipse(int x1, int y1, int x2, int y2,COLORREF colorForeground,COLORREF colorBackground) ; //write a string at position (x,y) in lineColor and background color as fillColor //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage example: myDrawText(100,200,40,"Good day",RGB(200,0,200),RGB(3,200,3)); void myDrawText(int x,int y,int ht,char str[],COLORREF lineColor,COLORREF fillColor); //write a string at position (x,y) in lineColor and background color as fillColor //the font size will be determined by the ht parameter //create a color using different values of red (R), green (G) and blue (B) //for example c is a color value, whose type is COLORREF: COLORREF c = RGB(30,300,20); //usage example: myDrawText(100,200,40,"Good day",RGB(200,0,200),RGB(3,200,3)); void myDrawTextWithFont(int x,int y,int ht,char str[],COLORREF lineColor,COLORREF fillColor); #endif Programming Fundamentals Project/Project Problem Statement.pdf   Programming Fundamentals  Section 1E&1F  Semester Project  FALL SEMESTER 2020  Teaching Assistant: Muhammad Kamran  l174308@lhr.nu.edu.pk   Brick And Bat Game      1        Problem Statement  Bricks and Bat game (traditionally paranoid) is a classic game where a player has a layer of                                  bricks on the top of the screen along with a bat at the bottom of the screen and he tries to                                          hit all the balls to gain scores and reach further levels. For this project we altered some of                                    its functionalities and want you to develop the same game with the customized                          requirements. Therefore, for this project the player’s main goal is to hit all the bricks with                                the ball before losing all of his lives in the game. The player loses one life if the ball does                                        not hit the bat and falls out of the screen. As far as it regards the layers of bricks,the                                      number of layers can be random but at max 7 layers. One layer can contain any number of                                    bricks. Moreover, Brick can be of more than one type illustrated below.    Note: Shape and the color of the bricks must be exactly the same as shown in the picture.      2        The player will win the game if all the bricks are removed. Every brick is removed when it                                    has been hit. The player will have 3 lives at the start of the game and it can reach up to a                                            maximum of 5 if he hits two green circle bricks in the game. You can use any type of array                                        to represent the layers of the bricks. Further requirements are explained below as:  Menu  As every game does have a menu this game will also have a menu. You can add as many as                                        options you want but these options are mandatory to be in the menu; Start a New Game,                                  Load Saved Game,Show Score History , Exit.  And of course, You can be creative in designing the menu.  Start of the Game  At the beginning of the game there will be a random number of layers at least 4 on the                                      screen and each of the layers will have a random number of bricks filling the screen. The                                  brick type will also be chosen randomly. But 60% of the bricks must be simple bricks. The                                  bat will be placed in the middle of the screen at the bottom and the ball will be placed on                                        it. Moreover, on the right corner of the screen, lives of the player and the score will be                                    displayed. The lives will be 3 and the score will be zero initially.  To start/pause the game user will press the space button.  Once the game is started, the ball will start moving diagonally and will come back to the                                  bottom of the screen after it hits something at the upper part of the screen and the player                                    will control the bat using an arrow button (left key or right key) so that he can prevent the                                      ball falling out of the screen.  Angles of trajectory of the ball  The bat can be divided into 5 parts ; left,left center, center,right center and right.   Left : 0-20% of the bat  Left center: 21%-40% of the bat    3        Center: 41%-60% of the bat  Right center: 61%-80% of the bat  Right: 81%-100% of the bat  If the ball hits the left part it will move with the angle 30 degree.  If the ball hits the left center part it will move with the angle 60 degree.  If the ball hits the center part it will move with the angle 90 degree.  If the ball hits the right center it will move with the angle 120 degree.  If the ball hits the right part it will move with the angle 150 degree.  Save Into File  The user will press “s” key to save the current state of the game into the file.  Score History  Score history will also be saved in a file and can be displayed if the player opts to “Show                                      Score history” from the menu. Only top 10 scores will be shown in history.  Instructions  1. You can use 2D arrays to represent the layers of the bricks.  2. You can use a specific range of numbers to map types of the bricks. For example                                you can say that 0 -> red triangle brick, 1->green circle brick, 2->yellow center                            brick,3->black centered brick,4 -> simple brick and 5 -> nothing. Now let’s say you                            want to represent 2 layers (one made of 3 bricks), you can represent in 2D array as      4  4  5  2  3  1  4          3. You can use any graphics library to implement the game; you can use the graphics                              files provided with the assignment 4 as well.( myEllipse function to print the ball,                            myLine to print the bat and other methods to print the bricks and scores etc).  4. You can not use goto,break or continue statements.  5. Only one level is required for this project.  6. You can do this project in pairs.  Submission Guidelines  1. Submit only one cpp file in format ​l20_abcd_l120_efgh.cpp ​.     Best Of Luck    5 

Related Questions

Similar orders to Fundamental Breakout game(brick breaker) using C++
5
Views
0
Answers
Will need help with 5 questions in C programming, the questions are pretty basic on high-school/collage level
I will get the assignment with 5 exercises/ questions on the 1st of March 10:30 am (UTC +02:00 time) and will need to have it in 2 hours if possible (easy questions for someone good), i'm attaching examples to the type/level of questions it will be, there...
9
Views
0
Answers
C programming assignment
everything is in the pdf....
8
Views
0
Answers
C++ Multi-Part Assignment
https://maryash.github.io/235/projects/project-1/project-1.html This is the assignment link with full details....
7
Views
0
Answers
Making a game of moving rover on a map
Just follow the instructions, and please add some comment so that I can understand what you are doing because I wanted to learn from your code...