Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Explain the changes you made to the code. Discuss the work you completed by focusing on the different tactics you used to create a fully
Explain the changes you made to the code. Discuss the work you completed by focusing on the different tactics you used to create a fully realized D animation. What were the changes you chose to make? What was your intent behind them? How did you approach coding to successfully create this outcome?
using namespace std;
const float DEGRAD ;
void processInputGLFWwindow window;
enum BRICKTYPE REFLECTIVE, DESTRUCTABLE, PADDLE ;
enum ONOFF ON OFF ;
class Brick
public:
float red, green, blue;
float x y width;
int health; track the brick's health
BRICKTYPE bricktype;
ONOFF onoff;
BrickBRICKTYPE bt float xx float yy float ww float rr float gg float bb
bricktype bt; x xx; y yy width ww; red rr green gg blue bb;
onoff ON;
health ;;
void drawBrick
if onoff ON
double halfside width ;
glColordred green, blue;
glBeginGLPOLYGON;
glVertexdx halfside, y halfside;
glVertexdx halfside, y halfside;
glVertexdx halfside, y halfside;
glVertexdx halfside, y halfside;
glEnd;;
Brick paddlePADDLE;
class Circle
public:
float red, green, blue;
float radius;
float x;
float y;
float speed ;
int direction; up right down left up right up left down right down left
ONOFF onoff;
Circledouble xx double yy double rr int dir, float rad, float r float g float b
x xx;
y yy;
radius rr;
red r;
green g;
blue b;
radius rad;
direction dir;
onoff ON;
void CheckCollisionBrick brk
if brkbricktype REFLECTIVE && onoff ON
if x brkx brkwidth && x brkx brkwidth && y brky brkwidth && y brky brkwidth
direction GetRandomDirection;
x x ;
y y ;
make a brick into a paddle that reflects balls and can move
else if brkbricktype PADDLE && onoff ON
if x brkx brkwidth && x brkx brkwidth && y brky brkwidth && y brky brkwidth
direction GetRandomDirection;
x x ;
y y ;
else if brkbricktype DESTRUCTABLE && brkonoff ON
&& brkhealth && onoff ON added check for ON to prevent destroyed bricks causing collisions
if x brkx brkwidth && x brkx brkwidth && y brky brkwidth && y brky brkwidth
brkhealth;
if brkhealth check brk health, if or less, turn brick off
brkonoff OFF;
brkgreen ; brk was hit but still has health, change color
direction GetRandomDirection;
x x ;
y y ;
int GetRandomDirection
return rand;
void MoveOneStep
if y radius
onoff OFF;
if direction direction direction up
if y radius
y speed;
else
direction GetRandomDirection;
if direction direction direction right
if x radius
x speed;
else
direction GetRandomDirection;
if direction direction direction down
if y radius
y speed;
else
direction GetRandomDirection;
if direction direction direction left
if x radius
x speed;
else
direction GetRandomDirection;
void DrawCircle
if onoff ON
glColorfred green, blue;
glBeginGLPOLYGON;
for int i ; i ; i
float degInRad i DEGRAD;
glVertexfcosdegInRad radius xsindegInRad radius y;
glEnd;;
vector world;
int mainvoid
srandtimeNULL;
if glfwInit
exitEXITFAILURE;
glfwWindowHintGLFWCONTEXTVERSIONMAJOR, ;
glfwWindowHintGLFWCONTEXTVERSIONMINOR, ;
GLFWwindow window glfwCreateWindow "Random World of Circles", NULL, NULL;
if window
glfwTerminate;
exitEXITFAILURE;
glfwMakeContextCurrentwindow;
glfwSwapInterval;
row of brick accross the middle
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE;
Brick brickDESTRUCTABLE
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started