What are the differences of in_place functions to non-ip ones and why do they exist?
When should one use for instance move()
,inflate()
and when to use
The in place function work, well, in place; they change the Rect
you call them on, while the non-in place functions return new instances of the Rect
class with the according changes.
You can use them anytime you actually want to change a Rect
, e.g. you have a Sprite
and want to move it, you can use
s = SomeSpriteClass()
s.rect.move_ip(100, 0)
instead of
s = SomeSpriteClass()
s.rect = s.rect.move(100, 0)
to move the Sprite
100 pixels to the right.
You would use the non-in place functions when you don't want to actually change the Rect
, e.g. when you only want to do some calculations, like implementing a camera function.