I’m having a problem where the program stops executing whenever I run certain lines of code when handling key presses and mouse clicks. I’m trying to accept certain inputs to create an object of certain mass, radius and velocity.
In particular, pressing any of the keys in the if statement, or executing the bodies.Append() line, will stop the program. The window will stay open but won’t allow further interaction. vel, bodies, incr, radius and mass are all global variables.
My advice when reading variable key is to apply this code: k = key.upper() if key != CODED else keyCode
Then use local variable k instead w/ capitalized letters like the example from this link:
k = key.upper() if key != CODED else keyCode
if k == 'W' or k == UP:
for f in flakes: f.vel.y -= f.maps[2]
elif k == 'S' or k == DOWN:
for f in flakes: f.vel.y += f.maps[2]
elif k == 'A' or k == LEFT:
for f in flakes: f.vel.x -= f.maps[2]
elif k == 'D' or k == RIGHT:
for f in flakes: f.vel.x += f.maps[2]
Ru sure that method is capitalized? If that’s a list type, it’s lower case instead: bodies.append(