Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ help xcode #include \"brickGame.h\" #include \"iostream.h\" struct brickBrea

ID: 3839045 • Letter: C

Question

C++ help xcode

#include "brickGame.h"

#include "iostream.h"

struct brickBreak

{

float q,s,w,h;

bool alive;

}b[45];

float red1,red2,green1,green2,blue1,blue2;

struct brickBall

{

float ballx,bally,ballwh,velx,vely;

float red;

float green;

float blue;

bool left,right,up,down;

}ball;

float red=0.0;

float green=0.0;

float blue=0.0;

struct brickBlockList

{

float myx;

float myy;

float width;

float height;

bool lft;

bool rgt;

float red;

float green;

float blue;

}block;

// Created a method called BrickBreakingGame

void BrickBreakingGame()

{

int m,q=4,s1=410;

for(m=0;m<45;m++)

{

q+=76;

if(q>470)

{

// Implemented variables

  

q=4;

s1-=35;

}

b[m].q=q;

b[m].s=s1;

b[m].w=60;

b[m].h=20;

b[m].alive=true;

}

  

block.myx=300;

block.myy=0;

block.width=80;

block.height=20;

block.lft=false;

block.rgt=false;

  

ball.ballx=300;

ball.bally=200;

ball.ballwh=30;

ball.velx=0.35;

ball.vely=0.35;

  

red1=0.96;

green1=0.8;

blue1=0.69;

red2=0.6;

green2=0.8;

blue2=0.196078;

  

ball.red=0.65;

ball.green=0.49;

ball.blue=0.24;

  

block.red=0.137255;

block.green=0.556863;

block.blue=0.419608;

  

}

bool check_collision(float Ax, float Ay, float Aw, float Ah, float Bx, float By, float Bw, float Bh) //Function for checking collision

{

if ( Ay+Ah < By ) return false;

else if ( Ay > By+Bh ) return false;

else if ( Ax+Aw < Bx ) return false;

else if ( Ax > Bx+Bw ) return false;

  

return true;

}

void reshape(){

if(block.myx<0)

block.myx=0;

if(block.myx+block.width>600)

block.myx=520;

if(block.lft==true)

block.myx=block.myx-0.05;

if(block.rgt==true)

block.myx=block.myx+0.05;

  

ball.ballx+=0.05*ball.velx;

ball.bally+=0.05*ball.vely;

  

for(int m=0;m<45;m++)

{

if(b[m].alive==true)

{

if(check_collision(ball.ballx,ball.bally,ball.ballwh,ball.ballwh,b[m].q,b[m].s,b[m].w,b[m].h)==true)

{

ball.vely=-ball.vely;

b[m].alive=false;

ball.down=true;

ball.up=false;

break;

}

}

}

if (ball.ballx < 0)

{

ball.velx=-ball.velx;

ball.right=true;

ball.left=false;

}

if(ball.ballx+ball.ballwh>600)

{

ball.right=false;

ball.left=true;

ball.velx=-ball.velx;

}

if(ball.bally+ball.ballwh>400)

ball.vely=-ball.vely;

else if(ball.bally<0)

exit(0);

  

if(check_collision(ball.ballx,ball.bally,ball.ballwh,ball.ballwh,block.myx,block.myy,block.width,block.height)==true)

{

ball.vely=-ball.vely;

ball.up=true;

ball.down=false;

}

draw();

}

void specialUp(int key,int q,int s)

{

switch(key)

{

case (GLUT_KEY_LEFT): block.lft=false;break;

case (GLUT_KEY_RIGHT): block.rgt=false;break;

}

}

void specialDown(int key,int q,int s)

{

switch(key)

{

case (GLUT_KEY_LEFT): block.lft=true;break;

case (GLUT_KEY_RIGHT): block.rgt=true;break;

}

}

void keyboard(unsigned char key,int q,int s)

{

if(key==27)

{

ball.velx=0;

ball.vely=0;

callMenu();

}

}

void myinit()

{

glViewport(0,0,600,400);

glLoadIdentity();

glShadeModel(GL_SMOOTH);

glMatrixMode(GL_PROJECTION);

gluOrtho2D(0,600,0,400);

}

void draw()

{

  

  

for(int i=0;i<45;i++)

{

if(b[i].alive==true)

{

if(i%2==0) glColor3f(red1,green1,blue1);

else glColor3f(red2,green2,blue2);

glBegin(GL_POLYGON);

glVertex2f(b[i].q,b[i].s);

glVertex2f(b[i].q+b[i].w,b[i].s);

glVertex2f(b[i].q+b[i].w,b[i].s+b[i].h);

glVertex2f(b[i].q,b[i].s+b[i].h);

glEnd();

}

}

  

  

glColor3f(block.red,block.green,block.blue);

glBegin(GL_POLYGON);

glVertex2f(block.myx,block.myy);

glVertex2f(block.myx+block.width,block.myy);

glVertex2f(block.myx+block.width,block.myy+block.height);

glVertex2f(block.myx,block.myy+block.height);

glEnd();

  

glColor3f(ball.red,ball.green,ball.blue);

glBegin(GL_POLYGON);

glVertex2f(ball.ballx,ball.bally);

glVertex2f(ball.ballx+ball.ballwh,ball.bally);

glVertex2f(ball.ballx+ball.ballwh,ball.bally+ball.ballwh);

glVertex2f(ball.ballx,ball.bally+ball.ballwh);

glEnd();

glutPostRedisplay();

glutSwapBuffers();

  

}

void display()

{

glClear(GL_COLOR_BUFFER_BIT);

glClearColor(red,green,blue,1);

glDisable(GL_DEPTH_TEST);

draw();

glFlush();

reshape();

}

void bg1_menu(int opt)

{

switch(opt)

{

case RED: red=1.0;

green=0.0;

blue=0.0;

display();

break;

case GREEN: red=0.0;

green=1.0;

blue=0.0;

display();

break;

case BLUE: red=0.0;

green=0.0;

blue=1.0;

display();

break;

case BLACK: red=0.0;

green=0.0;

blue=0.0;

display();

break;

}

  

}

void bg2_menu(int opt)

{

switch(opt)

{

case GOLD: ball.red=0.858824;

ball.green=0.858824;

ball.blue=0.439216;

break;

  

case ORCHID: ball.red=0.858824;

ball.green=0.439216;

ball.blue=0.858824;

break;

}

}

void bg3_menu(int opt)

{

switch(opt)

{

case C1:

red1=0.72;

green1=0.45;

blue1=0.20;

red2=0.42;

green2=0.26;

blue2=0.15;

break;

case C2:

red1=1;

green1=0.5;

blue1=0;

red2=0.9;

green2=0.91;

blue2=0.98;

break;

case C3:

red1=0.858824;

green1=0.439216;

blue1=0.858824;

red2=0.36;

green2=0.2;

blue2=0.09;

}

}

void bg4_menu(int opt)

{

switch(opt)

{

case BLACK1:

block.red=0.0;

block.green=0.0;

block.blue=0.0;

break;

case WHITE:

block.red=1;

block.green=1;

block.blue=1;

break;

}

}

void sp_menu(int opt)

{

switch(opt)

{

case INC:

ball.velx++;

ball.vely++;

break;

case DEC:

ball.velx-=0.35;

ball.vely-=0.35;

break;

  

}

}

void main_menu(int opt)

{

switch(opt)

{

case CONTINUE: revert();

break;

case QUIT: exit(0);

}

}

void callMenu()

{

int bg,bg1,bg2,bg3,bg4,sp;

bg1=glutCreateMenu(bg1_menu);

glutAddMenuEntry("Red",RED);

glutAddMenuEntry("Green",GREEN);

glutAddMenuEntry("Blue",BLUE);

glutAddMenuEntry("Default",BLACK);

  

bg2=glutCreateMenu(bg2_menu);

glutAddMenuEntry("gold",GOLD);

glutAddMenuEntry("Orchid",ORCHID);

  

bg3=glutCreateMenu(bg3_menu);

glutAddMenuEntry("Combo1",C1);

glutAddMenuEntry("Combo2",C2);

glutAddMenuEntry("Combo3",C3);

  

bg4=glutCreateMenu(bg4_menu);

glutAddMenuEntry("Black",BLACK1);

glutAddMenuEntry("White",WHITE);

  

sp=glutCreateMenu(sp_menu);

glutAddMenuEntry("Increase",INC);

glutAddMenuEntry("Decrease",DEC);

  

bg=glutCreateMenu(main_menu);

glutAddSubMenu("Background",bg1);

glutAddSubMenu("Ball",bg2);

glutAddSubMenu("Brick",bg3);

glutAddSubMenu("Block",bg4);

  

glutCreateMenu(main_menu);

glutAddMenuEntry("Continue",CONTINUE);

glutAddSubMenu("Color",bg);

glutAddSubMenu("Speed",sp);

glutAddMenuEntry("Quit Game",QUIT);

  

glutAttachMenu(GLUT_RIGHT_BUTTON);

  

  

}

void processmenu(int opt)

{

switch(opt)

{

case CONTINUE:

revert();

break;

case INC:

ball.velx++;

ball.vely++;

break;

  

case QUIT: exit(0);

}

  

}

void revert()

{

ball.velx=0.35;

ball.vely=0.35;

if(ball.up==true)

{

if(ball.right==true)

{

ball.velx=ball.velx;

ball.vely=ball.vely;

}

else if(ball.left==true)

{

ball.velx=-ball.velx;

ball.vely=ball.vely;

}

}

else if(ball.down=true)

{

if(ball.right=true)

{

ball.velx=ball.velx;

ball.vely=-ball.vely;

}

else if(ball.left==true)

{

ball.velx=-ball.velx;

ball.vely=-ball.vely;

}

}

}

int main(int argc,char *argv[])

{

glutInit(&argc,argv);

glutInitWindowSize(600,400);

glutInitWindowPosition(100,100);

glutCreateWindow("Block Breaker");

BrickBreakingGame();

myinit();

draw();

glutDisplayFunc(display);

glutSpecialFunc(specialDown);

glutSpecialUpFunc(specialUp);

glutKeyboardFunc(keyboard);

glutIdleFunc(reshape);

glutMainLoop();

return 0;

}

// This define function gives the default behavior of the program

#define CONTINUE 1

#define QUIT 0

#define RED 2

#define GREEN 3

#define BLUE 4

#define BLACK 5

#define INC 6

#define DEC 7

#define C1 8

#define C2 9

#define C3 10

#define GOLD 11

#define ORCHID 12

#define BLACK1 13

#define WHITE 14

// Created a structure brickBreak

typedef enum boolean {

false, true

}bool;

void specialUp(int,int,int);

void specialDown(int,int,int);

void reshape(void);

void draw(void);

void callMenu(void);

void processmenu(int);

void revert(void);

void main_menu(int);

l new game new game Gr ostream.cpp h iostream.h Gr brick Game.cpp h brickGame.h Products else if (balu.ballys0) 0 Use of undeclared identifier exit exit (0 if (check coulision(bauu.baux, balu.bally, balu.bauwh,bauu.bauwh,block.nyx,buock.myy,block.width,buock. height) true ball. vely -ball. vely; ball upstrue; ball down false Use of draw undeclared identifier 'draw void specialUp int key int int s) switch key block uft false break O Use of undeclared identifier GLUT KEY LEFT GLUT KEY LEFT Case 0 Use of undeclared identifier GLUT KEY RIGHT GLUT KEY RIGHT block. Irgt false;break Case void specia Down int key int q int s switch key block. ft true break 9 Use of undeclared identifier GLUT KEY LEFT case (GLUT KEY LEFT GLUT KEY RIGHT block. Irgt true break 9 Use of undeclared identifier GLUT KEY RIGHT Case void keyboard unsigned char key, int q, int s) if(key 27) ball. veux ball. vely O Use of undeclared identifer callMenu cal UMenu void my init g Viewport (0,0, 600,400) 9 Use of undeclared identifier "glViewport auLoad Identity 9 Use of undeclared identifier glLoadldentity glShadeModel (GL SMOOTH); O use of undeclared identifor GLsMooTH guMatrixMode(GL PROJECTION) 9 Use of undeclared identifier GL PROJECTION quuOrtho2D (0,600, 0,400) 0 Use of undeclared identifier giuortho2D void draw for (int i 0:i

Explanation / Answer

Please add the VALUES to the GL______ in the header files,otherwise everytime the errors will be shown.And, exit(0) header required header file is not included due to which the errors are shown.I had already changed this code many times, you had reposted the program 4th time.Please add the identifiers in the header file or else please provide the entire code once so that we can it.I changed everytime for the given part of the question

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote