sep-pm-platformer/project/sprite/PositionScale.py

15 lines
567 B
Python
Raw Permalink Normal View History

2023-03-24 17:41:48 +01:00
class PositionScale:
2023-03-26 15:14:06 +02:00
def __init__(self, position: tuple[float, float] = (0, 0), scale: tuple[float, float] = (1, 1)):
2023-03-26 17:01:28 +02:00
self.position: tuple[float, float] = position
self.scale: tuple[float, float] = scale
2023-03-24 17:41:48 +01:00
def apply_scale_to_position(self):
return self.position[0] * self.scale[0], self.position[1] * self.scale[1]
@staticmethod
def combine(a, b):
return PositionScale(
(a.position[0] + b.position[0], a.position[1] + b.position[1]),
(a.scale[0] * b.scale[0], a.scale[1] * b.scale[1])
)