-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a simple menu, A point counter has been added, Added the highest score counter (only for the current game), Life counter added
- Loading branch information
Showing
7 changed files
with
280 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Kod odpowiedzialny za utworzenie przycisku w pygame.""" | ||
import pygame.font | ||
|
||
|
||
class Button: | ||
"""Klasa tworząca przycisk button.""" | ||
|
||
def __init__(self, ai_settings, screen, msg): | ||
"""Inicjalizacja atrybutów przycisku. | ||
:param ai_settings: Ustawienia | ||
:param screen: Ekran | ||
:param msg: Tekst wyświetlany na przycisku | ||
""" | ||
self.screen = screen | ||
self.screen_rect = screen.get_rect() | ||
|
||
# Zdefiniowanie wymiarów i właściwości przycisku. | ||
self.width, self.height = 250, 50 | ||
self.button_color = (0, 255, 0) | ||
self.text_color = (255, 255, 255) | ||
self.font = pygame.font.SysFont(None, 48) | ||
|
||
# Utworzenie prostokąta przycisku i wyśrodkowanie go. | ||
self.rect = pygame.Rect(0, 0, self.width, self.height) | ||
self.rect.center = self.screen_rect.center | ||
|
||
# Komunikat wyswietlany przez przycisk trzeba przygotować tylko jednokrotnie | ||
self.prep_msg(msg) | ||
|
||
def prep_msg(self, msg): | ||
"""Umieszczenie komunikatu w wygenerowanym obrazie i wyśrodkowanie tekstu na przycisku. | ||
:param msg: Tekst wyswietlany na przycisku | ||
""" | ||
self.msg_image = self.font.render(msg, True, self.text_color, self.button_color) | ||
self.msg_image_rect = self.msg_image.get_rect() | ||
self.msg_image_rect.center = self.rect.center | ||
|
||
def draw_button(self): | ||
"""Wyświetlenie pustego przycisku, a następnie komunikatu na nim.""" | ||
self.screen.fill(self.button_color, self.rect) | ||
self.screen.blit(self.msg_image, self.msg_image_rect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.