I'm not very familiar with pygame
, so this is just a guess. However, the thing that looks most like a problem to me is this line (inside the definition of moveShape
):
shape = shape.move(speed)
The reason this is a problem is that shape
is the name of a local variable within moveShape
, but I'm guessing that you intend by the equals assignment to update the nonlocal shape
object (the one declared at the top of your main()
definition. When you call shape.move(speed)
, the return value is a new pygame
Rect
object, which gets assigned the name shape
. But this assignment happens inside the moveShape
function, and so the update is not visible outside that scope.
It looks like you can replace this line with an "inplace" version (http://www.pygame.org/docs/ref/rect.html#pygame.Rect.move_ip) that will change the object without returning a new one:
shape.move_ip(speed)
Maybe that will work for you?