Skip to content

Commit

Permalink
Изменения в сцене headpiece для FPS независимости
Browse files Browse the repository at this point in the history
  • Loading branch information
YariKartoshe4ka committed Dec 12, 2021
1 parent 542d1fc commit ad6b7b8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spaceway/scenes/headpiece/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ def __init__(self, screen, base_dir, config):
self.img_heart = pygame.image.load(f'{base_dir}/assets/images/heart/heart.bmp')
self.rect_heart = self.img_heart.get_rect()
self.is_heart = False
self.tick = 0

self.base_dir = base_dir

CaptionMixin.__init__(self, base_dir, config, 'YariKartoshe4ka')

def update(self):
if self.config['ns'].tick % (self.config['FPS'] * 4) == 0:
self.tick += self.config['ns'].dt / 30

if self.tick > 4:
self.config['scene'] = self.config['sub_scene'] = 'lobby'

elif self.config['ns'].tick % (self.config['FPS'] * 2) == 0:
elif self.tick > 2 and not self.is_heart:
self.caption = 'With love'
self.is_heart = True

Expand Down Expand Up @@ -62,14 +65,13 @@ def __init__(self, screen, base_dir, config):
)[self.config['user']['color']]

self.line = Rect(0, self.config['mode'][1] - 5, 0, 5)
self.inc = self.config['mode'][0] / (self.config['FPS'] * 4)

self.font = pygame.font.Font(f'{base_dir}/assets/fonts/pixeboy.ttf', 22)

def update(self):
self.line.width += self.inc
self.line.width += self.config['ns'].dt * self.config['mode'][0] / 120

self.img = self.font.render(f"{round(self.line.width * 100 / self.config['mode'][0])}%", True, self.color)
self.img = self.font.render(f"{min(100, round(self.line.width / self.config['mode'][0] * 100))}%", True, self.color)
self.rect = self.img.get_rect()

self.rect.centerx = max(
Expand Down

0 comments on commit ad6b7b8

Please sign in to comment.