help "deleting" an "object" and array for classes

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
In my game, I have an "object" (its just a class), call it coin. And in my main process, coin is started up like socoin coin( i, x, y );
and then when main gets into a loopwhile( quit == false )
there is this other coin codecoin.collision( player.get_rects() );
coin.show;
because if they arent in the loop. then they appear/disappear after a split second. Now I do have the collision working.void coin::collision( std::vector<SDL_Rect> &rects )
{
if( check_collision( box, rects ) )
{
cout << "has collided with player, can now end" << endl;
return;
}
}
The problem is (I think), that since it is in the loop, it is checking the collision constantly, even if return means it has ended. So this is where I am stuck. I even tried starting the code before my loop by simply putting in the while( quit == false ) statement but when the game loaded up it froze, and I know thats because It has to wait for check_collision to be over now. So this is where I am stuck. I have an idea that just popped into my head, I will try it later.
Now I want to do an array with coin, but doing something like coin coin(i,x,y) wont work. Any suggestions? Thanks

View the full article
 
Back
Top