I am making a Bubble Pop game in C++ where the user clicks on randomly generated Bubbles that float up the screen(still very much in development). In order to Use OpenGl and Glut with this game I found that it was best to make my Bubbles global. I have a blank destructor but I do not know how to delete the contents of the Bubble and create a new one. I tried using dynamic allocation but it didn't make a difference. How can I delete the contents of the Bubble and make a new one?
Here's a necessary snippet: main.cpp
Bubble myBubble1; void display(void) {
delete myBubble1;//error "cannot delete type Bubble"
}
My destructor is here:
class Bubble {
public:
//default constructor
Bubble()
{
radius=(rand() % 100 )+1;
speed = rand() % 500 ;
xVal = rand() % 480;
yVal= -14;
isLive=true;
}
~Bubble()
{
}
private:
float radius;
float speed;
float xVal;
float yVal;
bool isLive;
};
The code runs fine when I don't try to delete anything. I can run infinite looping bubbles