Display countdown at bottom of the screen
parent
f76851ba23
commit
f67ec8b037
|
@ -47,18 +47,28 @@ class CaptureButton(Button):
|
||||||
self.capture_mode = False
|
self.capture_mode = False
|
||||||
self.count = 0
|
self.count = 0
|
||||||
|
|
||||||
|
self.background_rect = pygame.Rect(0, self.photoboite.screen.get_height() - 80, self.photoboite.screen.get_width(), 80)
|
||||||
|
self.background = pygame.Surface((self.background_rect.width, self.background_rect.height))
|
||||||
|
self.background.fill((0, 0, 0))
|
||||||
|
self.background.set_alpha(150)
|
||||||
|
|
||||||
|
self.font = pygame.font.Font(None, 80)
|
||||||
|
|
||||||
def draw_on(self, screen):
|
def draw_on(self, screen):
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
super(CaptureButton, self).draw_on(screen)
|
super(CaptureButton, self).draw_on(screen)
|
||||||
if self.capture_mode:
|
if self.capture_mode and self.elapsed < CaptureButton.countdown:
|
||||||
if self.elapsed >= CaptureButton.countdown:
|
screen.blit(self.background, self.background_rect.topleft)
|
||||||
text = "CLIC!"
|
|
||||||
else:
|
text = str(CaptureButton.countdown - self.elapsed)
|
||||||
text = str(CaptureButton.countdown - self.elapsed)
|
size = self.font.size(text)
|
||||||
size = self.photoboite.font.size(text)
|
ren = self.font.render(text, True, (255, 255, 255))
|
||||||
ren = self.photoboite.font.render(text, True, (0, 0, 0))
|
ren.set_alpha(150)
|
||||||
|
|
||||||
topleft = (self.rect.topleft[0] + self.rect.width / 2 - size[0] / 2, self.rect.topleft[1] + self.rect.height / 2 - size[1] / 2)
|
topleft = (self.rect.topleft[0] + self.rect.width / 2 - size[0] / 2, self.rect.topleft[1] + self.rect.height / 2 - size[1] / 2)
|
||||||
screen.blit(ren, topleft)
|
top = self.background_rect.top + self.background_rect.height / 2 - size[1] / 2
|
||||||
|
left = self.background_rect.left + self.background_rect.width / 2 - size[0] / 2
|
||||||
|
screen.blit(ren, (left, top))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
pygame.event.set_blocked((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
pygame.event.set_blocked((pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP))
|
||||||
|
@ -155,8 +165,6 @@ class Photoboite:
|
||||||
camera_rect = pygame.Rect(0, 0, 800, 480)
|
camera_rect = pygame.Rect(0, 0, 800, 480)
|
||||||
self.camera = Camera(camera_rect)
|
self.camera = Camera(camera_rect)
|
||||||
|
|
||||||
self.font = pygame.font.Font(pygame.font.match_font('calibri'), 180)
|
|
||||||
|
|
||||||
self.clock = pygame.time.Clock()
|
self.clock = pygame.time.Clock()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue