SDL screen not updating properly?

This is a discussion on SDL screen not updating properly? within the Game Programming forums, part of the General Programming Boards category; I'm not sure which part of my code you'd like to see, and I don't think posting all 5 of ...

  1. #1
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532

    SDL screen not updating properly?

    I'm not sure which part of my code you'd like to see, and I don't think posting all 5 of my source files is neccessary, so I'm just going to ask a general question. In my SDL program, I have a sprite that when moved(responding to appropriate key presses) it does move, yet it leaves a sort of "drag"(bits of the sprite's image) behind. This "drag" sticks and stays on the screen, naturally this is not desirable. I DO call SDL_Flip each loop and in past SDL programs I've not encountered this. Below is a screenshot, and if anyone has any idea as to what needs to be fixed, I'd appreciate it. If you need to see a certain section of code, then I'll be happy to oblige. Thanks again.
    Attached Images Attached Images  
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  2. #2
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    SDL_Flip() will just update the screen. The problem is probably that you don't clear the screen before drawing each frame.

  3. #3
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Clear the screen? If you would, explain a little more? I've blitted sprites before with virtually the same routine.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

  4. #4
    Mad OnionKnight's Avatar
    Join Date
    Jan 2005
    Location
    Umeň, Sweden
    Posts
    555
    Basically you draw a big black rectangle that covers the whole screen to wipe out all the old stuff, then start drawing new stuff.

  5. #5
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Location
    MI
    Posts
    532
    Ahh gotcha. My old routine loaded the background each time so that's why it didn't have this issue. Thanks.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."
    c9915ec6c1f3b876ddf38514adbb94f0

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SDL + Keys
    By Livijn in forum Game Programming
    Replies: 24
    Last Post: 05-11-2007, 04:31 PM
  2. SDL + Newbie
    By Livijn in forum Game Programming
    Replies: 7
    Last Post: 04-30-2007, 11:20 PM
  3. Laptop LCD Screen
    By mkylman in forum Tech Board
    Replies: 8
    Last Post: 11-11-2006, 07:27 PM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. Loading Screen
    By pinkcheese in forum Windows Programming
    Replies: 2
    Last Post: 04-06-2002, 10:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21