Different colors crashing tetris
I have written a simple tetris clone using Windows GDI for graphics. I have several COLORREF values stored as constants. There is one variable in a GamePiece class that conbtrols the color of the piece. When it is a RED, BLUE, or GREEN color, it works fine. But when I try to mix colors, and set it at ORANGE, the game blocks all disipear after about 12 blocks have dropped. There is NOTHING in my code that depends on the color of the block. This is very strange.
I was able to figure it out. Apparently, I had a loop that was creating a new solid brush each time the loop went through, but I only deleted the brush after the loop ended, so I had a bunch of brushes floating around in memory. I simply moved the DeleteObject() call into the loop, and voila! It worked. But that dosen''t explain how it could run when only Red, Green, or blue was specified--do these colors take up less memory or something(They are all the same datat type, COLORREF, so i wouldn''t think so).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement