So, my breakout game is half finish. I have collision detection, load and destroy functions, as well as render functions.
for some cool effect, the particle system will have to get involved. I have particles for the ball when it collides to the walls and the bar. The final thing is the particles for the bricks. There will be 5 or 6 pieces of quad (or triangles) fly out randomly when the ball hit the bricks. But, there are certain problems i'm just unsure about.
- I start the game by loading the position, textures from a file and create the bricks for the level, and this is my brick class:
Then i create an array of vector and push all the brick objects and empty the load function.
vect2 *BuildBlock(int width, int height)
Vertices = new vect2;
Vertices = vect2(0, 0);
Vertices = vect2(width, 0);
Vertices = vect2(width, height);
Vertices = vect2(0, height);
glTranslated(Pos.x, Pos.y, 0.0f);
glColor3f(1, 1, 1);
for(int j=0; j<4; j++)
Vertices = NULL;
So when the ball hit one of the brick, the vector will erase the block out the array:
Now, there is the hard part, should i include the particle function in the brick class and then delay the destroy function? Because once the block is erase out the vector array, the particle function will not run. The other way is create an outside particle function and set the particles' position equal the brick's position that had been hit. Then i realize, the particles' position must be going somewhere before it can be reuse at another time when another brick is hit. (make sense?)
for(int j=0; j<block.size(); j++)
if(ball is collide with the bricks)
Can anyone point out a better way for this problem? Thanks