1

I'm currently making a game with pygame. I have one issue with my game at the moment.

  1. The scrolling of the screen is fine, but once the image has been scrolled completely after its second time (it works fine first time) the screen blit goes all weird, all the sprites in the game leaves massive trails behind where it was previously (check screnshots). This is simply because for some stragnge reason the variable "x" is not being reset back to 0 once it has exceeded the screenwidth after the second time, it resets after it equal 1384 the first time but not after the second time..

any help is greatly appreciated.

http://pastebin.com/ub6gi8Zn (pastebin code gone)

Blit working fine before background has repeated itself twice SCREENSHOT Blit working fine before background has repeated itself twice **SCREENSHOT**

gyazo.com/aa5626d4927b0b9299ce2ec42c9ba501 -- after the background repeating itself twice-- sorry couldn't add more than 2 links

1
  • This error has nothing the title of the post or the tags. Also your pastebin link doesn't work, put a testcase in the question. Also² you can embed images inside the question, you don't need to link them. Commented Oct 26, 2013 at 23:33

1 Answer 1

1

The problem is that you aren't clearing the screen buffer.

That is, the sprites and background just get redrawn over themselves because you haven't erased the pixels of the last time you drew those sprites on the screen!

I have never used pygame before but this is a general graphics programming problem, I tried looking up and it seems the function you are looking for is screen.fill(some_color). You fill the entire screen with a given color so the output of the last drawn frame disappear.

By the way this also happens because your "background" doesn't fill the entire area of the screen.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks it solved it, I cant vote up because I don't have enough rep. however if I would I could :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.