using c++ classes and vectors
I have a bouncing bubble just confused on how to generate randomvalues for vectors with class
We want to replace our single Bubble object with a vector ofBubbles. Before your draw loop, create a vector of five bubbles.Give each bubble a random starting position between 100 and 400 forX and Y and a random direction between 0.0 and 2.5 (think how to dothis with rand() to get a range within a double value. We don’twant the values to be 0, 1, 2. It should be possible for 0.7 or 1.3or 2.4 to be the random value set). Additionally, give each Bubblea random radius between 10 and 50. Lastly, give each Bubble arandom color so we can tell them apart.
Inside our draw loop, we now need to draw all the Bubbles in ourvector. After our event handling, we’ll then need to update thepositions of all the Bubbles in our vector. You should now see fiveBubbles bouncing around the window. Excellent. Let’s have the userinteract.
When the user clicks the left mouse button, we want to create a newBubble at the location where the user clicked. This new Bubbleshould have the same starting properties that our original fiveBubbles did. After the user clicks the first time, we should seesix Bubbles moving around the window. A second click, sevenBubbles. And so forth as the user continues to click. (Hmm, how canwe keep track of these new Bubbles?)
We may get to the point where there are too many Bubbles on thescreen. If the user presses the ‘d’ or ‘D’ key, then we want todelete the last Bubble that was added to the window. Obviously ifthere are no Bubbles in the window, then pressing ‘d’ should donothing.
If the user starts your program, clicks twice, then presses ‘d’three times, we should be seeing four Bubbles on the screen.
Answer to using c++ classes and vectors I have a bouncing bubble just confused on how to generate random values for vectors with c…