Why is the variable automatically going to 255 when I try to add it by 1?
Question:
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
Answers:
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
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
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