Code: Select all
SDL_FillRect(game.GetBuffer(), NULL, SDL_MapRGB(game.GetBuffer()->format, 0, 0, 0));
Thanks in advance everyone!
Moderator: Coders of Rage
Code: Select all
SDL_FillRect(game.GetBuffer(), NULL, SDL_MapRGB(game.GetBuffer()->format, 0, 0, 0));
Code: Select all
while(!gameOver)
{
......///////////////Update Stuff////////////////////////////.....
.
.
.
.
.
//////////////////////////// DRAW STUFF \\\\\\\\\\\\\\\\\\\\\\\\\\\\
if (screen == 1){ ////// FOR MENU SCREEN \\\\\\\\\
if (SDL_FillRect( game.GetBuffer(), NULL, SDL_MapRGB(game.GetBuffer()->format, 0, 0, 0)) != 0){
cerr << "SDL_FillRect() Failed: " << SDL_GetError() << endl;
exit(1);
}
if (SDL_BlitSurface(menuScreen, NULL, game.GetBuffer(), NULL) != 0) {
cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl;
exit(1);
}
}
else if (screen == 2) { ////////// FOR ABOUT SCREEN (not done yet) \\\\\\\\\\\\\\\\
if (SDL_FillRect( game.GetBuffer(), NULL, SDL_MapRGB(game.GetBuffer()->format, 0, 0, 0)) != 0) {
cerr << "SDL_FillRect() Failed: " << SDL_GetError() << endl;
exit(1);
}
// Draw the about screen
}
else if (screen == 3) { ////////////// DRAW THE GAMEPLAY SCREEN \\\\\\\\\\\\\\\\\
if (SDL_FillRect( game.GetBuffer(), NULL, SDL_MapRGB(game.GetBuffer()->format, 0, 0, 0)) != 0) {
cerr << "SDL_FillRect() Failed: " << SDL_GetError() << endl;
exit(1);
}
if (SDL_BlitSurface(bkground, NULL, game.GetBuffer(), NULL) != 0) {
cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl;
exit(1);
}
pillRect.x = static_cast<int>(pillX); // For calculating where to draw the pills as they fall from the
pillRect.y = static_cast<int>(pillY); // top of the screen to the bottom
// Draw the current pill
if (SDL_BlitSurface(pill, NULL, game.GetBuffer(), &pillRect) != 0) {
cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl;
exit(1);
}
rect.x = static_cast<int>(x); // For calculating where to draw the player this frame
rect.y = static_cast<int>(y);
// Draw the player
if (SDL_BlitSurface(image, NULL, game.GetBuffer(), &rect) != 0) {
cerr << "SDL_BlitSurface() Failed: " << SDL_GetError() << endl;
exit(1);
}
std::stringstream ss;
ss << score;
DrawText(game.GetBuffer(), scoreText + ss.str(), 10, 10, 14, WHITE);
}
// Update the display
SDL_Flip(game.GetBuffer());
}
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Code: Select all
SDL_Surface *bkground;
bkground = game.LoadImage("bkground.png");
Code: Select all
SDL_Surface* Game::LoadImage(const char *filename)
{
SDL_Surface *image = IMG_Load(filename);
if (image == NULL)
{
std::cerr << "SDL_LoadBMP() Failed: " << SDL_GetError() << std::endl;
exit(1);
}
Uint32 colorkey = SDL_MapRGB(image->format, 0xFF, 0, 0xFF);
SDL_SetColorKey(image, SDL_SRCCOLORKEY, colorkey);
return image;
}
Code: Select all
SDL_DisplayFormatAlpha(surface);
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Which drawing statement are you talking about specifically? And the answer is because 1. I don't know the difference between the two and 2. I didn't even know about SDL_DisplayFormatAlpha(); (I'm still learning SDL)sk1v3r wrote:I'm not quite sure :/
One nitpick though, how come you aren't using?Code: Select all
SDL_DisplayFormatAlpha(surface);
It probably won't have anything to do with it , but you've been very error safe with the rest of your code
I commented out all of the drawing code for when screen == 1 (menuscreen) and it didn't help at all. Here is a screen shot of the game when it is in the gameplay state and displaying the gameplayscreen (i.e. screen == 3)sk1v3r wrote:if you comment out when you first blit the menu screen does it stop the problem? (just troubleshooting here)