self.elevator.panel_prio = False
return True
+ def scale(self, topleft, size):
+ return Rect(topleft * self.rect.size, size * self.rect.size)
+
def draw(self, surf):
# clean me up!
subsurf = surf.subsurface(self.rect)
right_current = right_open - (right_open - right_closed) * state_fract
if left_current < door_size[0]:
- rect = Rect(
- Vec(0, self.DOOR_MARGIN[1]) * self.rect.size,
- Vec(left_current, door_size[1]) * self.rect.size,
+ rect = self.scale(
+ Vec(0, self.DOOR_MARGIN[1]), Vec(left_current, door_size[1])
)
else:
- rect = Rect(
- Vec(left_current - door_size[0], self.DOOR_MARGIN[1]) * self.rect.size,
- door_size * self.rect.size,
+ rect = self.scale(
+ Vec(left_current - door_size[0], self.DOOR_MARGIN[1]), door_size
)
pygame.draw.rect(subsurf, self.FOREGROUND, rect)
if right_current > (1 - door_size[0]):
- rect = Rect(
- Vec(right_current, self.DOOR_MARGIN[1]) * self.rect.size,
- Vec(1 - right_current, door_size[1]) * self.rect.size,
+ rect = self.scale(
+ Vec(right_current, self.DOOR_MARGIN[1]),
+ Vec(1 - right_current, door_size[1]),
)
else:
- rect = Rect(
- Vec(right_current, self.DOOR_MARGIN[1]) * self.rect.size,
- door_size * self.rect.size,
- )
+ rect = self.scale(Vec(right_current, self.DOOR_MARGIN[1]), door_size)
pygame.draw.rect(subsurf, self.FOREGROUND, rect)
pygame.draw.circle(
surf,
self.INNER_SIZE * self.outer_rect.size,
)
num_buttons = num_levels + 1
- button_outer_size = int(self.inner_rect.height / num_buttons)
- button_inner_size = int(self.inner_rect.height * self.BUTTON_SIZE / num_buttons)
+ button_outer_size = self.inner_rect.height / num_buttons
+ button_inner_size = self.inner_rect.height * self.BUTTON_SIZE / num_buttons
button_space = button_outer_size - button_inner_size
- self.font = pygame.font.Font(None, size=button_outer_size * 2 // 3)
+ self.font = pygame.font.Font(None, size=int(button_outer_size * 2 / 3))
self.buttons = [
Rect(
(
self.inner_rect.centerx - button_inner_size // 2,
self.inner_rect.top
- + int((self.inner_rect.height - button_space) / num_buttons)
+ + (self.inner_rect.height - button_space) / num_buttons
* (num_buttons - 1 - i)
+ button_space,
),