Hi. I am using SDL in MS Visual C++ 6.0, and I am making a breakout clone. Well, I have the basic main menu done, and I have it drawing the paddle and the ball when you select "New Game". But the problem is, I'm trying to draw a background image, also.
When I draw the paddle and ball alone, it's fine. But when I draw the background image, the sprites tend to flicker.
Here is my code for drawing:
SDL_FillRect(g_pScreen, NULL, 0); // Clear the screen
gamebg.Display(g_pScreen, 0, 0);
paddle.Display(g_pScreen, paddleX, (480 - paddle.GetHeight()*2));
ball.Display(g_pScreen, paddleX, 225);
What could be the problem here. BTW, here is the code for drawing an image using my image class (which is what those images use):
SDL_Rect dest; // Destination rectangle
dest.x = x; // Setup image's x
dest.y = y; // and y coordinates
dest.w = m_pImage->w; // Setup image's width
dest.h = m_pImage->h; // and height
SDL_BlitSurface(m_pImage, NULL, pScreen, &dest); // Draw the image
SDL_UpdateRects(pScreen, 1, &dest); // Update changed portion of screen
Well, thanks in advance. I'll be here for a while. I hope someone can help! =)
Thanks,
Matt U.
P.S.: BTW, how is my coding style (formatting, comments, etc.)? ;) (Curiosity gets to me sometimes. =P