Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why is the variable automatically going to 255 when I try to add it by 1?

So I have a variable set to go up by "1" in a pygame loop, for a fade effect. For some reason, it’s going to 255 when I want to go up by 1 at a time. Here’s what I have:

while alph <= 255:
    alph += 1

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Likely, if you’re working with a game, there’s already a looping function built into pygame, where each time it finishes a loop that’s a completed frame. Thus, during a single pygame loop (single frame) it encounters the code you’ve written here, and must update alph from 0 to 256 all in one frame before it can exit your loop and refresh/rerender your UI

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading