Question: } else if ( randomNum = = 2 ) { if ( this - > fCollision ( aRectangle ) ) { aRectangle.fPlot ( ) ;

}else if (randomNum ==2){ if (this->fCollision(aRectangle)){ aRectangle.fPlot();} this->moveDiagonalNegRight(); this->moveUp(); }}//randomly selects the direction of the object when it's at the coordinate (0,0)
if (this->xInit ==600 && yInit ==500){if (randomNum ==1){ if (this->fCollision(aRectangle)){ aRectangle.fPlot();} this->moveLeft(); this->moveUp(); }
} this->moveDiagonalPosLeft(); this->moveRight(); }}//randomly selects the direction of the object when it's at the coordinate (600,500)
if (this->xInit ==600 && yInit ==0){if (randomNum ==1){ this->moveDiagonalPosRight(); } else if (randomNum ==2){ if (this->fCollision(aRectangle)){ aRectangle.fPlot(); } this->moveDiagonalNegLeft(); this->moveRight(); }}//randomly selects the direction of the object when it's at the coordinate (600,0)
if (this->xInit ==0 && yInit ==500){if (randomNum ==1){ if (this->fCollision(aRectangle)){ aRectangle.fPlot();} this->moveRight(); this->moveDiagonalPosLeft(); } else if (randomNum ==3){ if (this->fCollision(aRectangle)){ aRectangle.fPlot(); }}//// randomly selects the direction of the object when it's at the coordinate (0,500)
}//function for gliding the object bool collision = false;return (collision = true);
}
int Rect::randomNumber(){int randomNum =(rand()%3)+1;}
int Rect::randomDirection(){return ((rand()%10)+1);
}
Rect::~Rect(){}//destructorIn main, it must be edited so that Rect class objects go into a dynamic memory array with
the new and delete commands. Encode two objects with the dynamic array. The first
object calls the default constructor, but the second object uses the setters functions to
define each of its attributes. Also, the code was modified so that how many objects are
alive at the moment appear on the screen..
int main(){
const int totalObj =2;
??? Hace que la pantalla mida 600500
SetWindowPos(myConsole,0,0,500,600,500, SWP_NOMOVE|SWP_NOZORDER);
Rect* rectangles = new Rect [totalObj];
rectangles[1].setBase(100);
rectangles[1].setAltura(100);
rectangles 1.setCoords(600,500A. The program is a continuation of the previous project. Add a function called fCollision
which has a variable of type Rect as a parameter. This new function should compare if
the two rectangles are in the same place. If they are, fCollision returns a true value which
will be received within fGlide. Within each path option within fGlide, it will be checked
for a collision. If it happens, the rectangle will head in a new premeditated direction.-base : double
-altura : double
-xlnit : double
-yInit : double
-color : COLORREF
-objCounter : static int
+setBase(double): void
+setAltura(double): void
+getBase() : double
+getAltura(): double
+setColor(COLORREF): void
+setCoords(double, double): void
+randomNumber() : static int
+randomDirection() : static int
+printObjectAmount() : static void
+fPlot() : void
+fErase() : void
+mooveCoords(double, double): double
+moveUp() : void
+moveDown(): : void
+moveLeft() : void
+moveRight() : void
+moveDiagonalPosRight() : void
+moveDiagonalPosLeft() : void
+fGlide(const Rect) : void
+fCollision(const Rect): boolAdd a new function called randomDirection () which will be called in the functions that
move the object diagonally so it takes random paths every iteration in the main. Modify
the code for the functions that move the object so that it can crash anywhere on the screen
and bounce.if (this->xInit ==0 && this->yInit ==0){ if (randomNum ==1){ if (this->fCollision(aRectangle)){
 }else if (randomNum ==2){ if (this->fCollision(aRectangle)){ aRectangle.fPlot();} this->moveDiagonalNegRight(); this->moveUp(); }}//randomly selects

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!