Closed geraintwhite closed 10 years ago
Wouldn't both be supported if you just used lists for it all? Or is that what you did?
As tuples aren't immutable, I changed Sprite.move()
so it creates new tuples:
p = self.position
if direction == 0:
p = (p[0], p[1]+1)
elif direction == 1:
p = (p[0]-1, p[1])
elif direction == 2:
p = (p[0], p[1]-1)
elif direction == 3:
p = (p[0]+1, p[1])
self.position
So now it will work with both, yes.
I suppose I could have used list()
to convert the tuples.
In sprite.py self.position is stored as a list. You pass a tuple when creating a Sprite, which is then converted to a list.
Sprite.move()
will only work for a list, so if you want to change the position directly you must use a list.It would make sense to either document this fact or to rewrite
Sprite.move()
so it works with tuples.In clock.py you are using tuples which will not work if you were to call
Sprite.move()
afterwards.