Compare commits
2 Commits
b78b29f22b
...
e2289fc3a2
| Author | SHA1 | Date |
|---|---|---|
|
|
e2289fc3a2 | |
|
|
fa3a4137b7 |
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit b78b29f22b5a861ecdcfd805049f8a774120cfc1
|
||||||
19
main.py
19
main.py
|
|
@ -20,6 +20,7 @@ enemy_img = pygame.image.load('Sprite-0001.png').convert()
|
||||||
enemy_img = pygame.transform.scale(
|
enemy_img = pygame.transform.scale(
|
||||||
enemy_img,
|
enemy_img,
|
||||||
(int(enemy_img.get_width() * 0.3), int(enemy_img.get_height() * 0.3)))
|
(int(enemy_img.get_width() * 0.3), int(enemy_img.get_height() * 0.3)))
|
||||||
|
enemy_img.set_colorkey((0, 0, 0))
|
||||||
|
|
||||||
#end ekrāns
|
#end ekrāns
|
||||||
end_img = pygame.image.load('Sprite-0002.png').convert()
|
end_img = pygame.image.load('Sprite-0002.png').convert()
|
||||||
|
|
@ -76,6 +77,7 @@ class Player(pygame.sprite.Sprite):
|
||||||
self.rect.centery = self.lane_centers[self.current_lane]
|
self.rect.centery = self.lane_centers[self.current_lane]
|
||||||
|
|
||||||
|
|
||||||
|
# Vētras klase
|
||||||
# Vētras klase (sarkanās blokas)
|
# Vētras klase (sarkanās blokas)
|
||||||
class Enemy(pygame.sprite.Sprite):
|
class Enemy(pygame.sprite.Sprite):
|
||||||
def __init__(self, image, lane_centers, speed=5):
|
def __init__(self, image, lane_centers, speed=5):
|
||||||
|
|
@ -94,6 +96,7 @@ class Enemy(pygame.sprite.Sprite):
|
||||||
|
|
||||||
|
|
||||||
def draw_end_screen(screen, final_score, high_score):
|
def draw_end_screen(screen, final_score, high_score):
|
||||||
|
# Puscaurspīdīgais tumšais fons
|
||||||
"""Draw the game over overlay with final score and options."""
|
"""Draw the game over overlay with final score and options."""
|
||||||
# Semi-transparent dark overlay
|
# Semi-transparent dark overlay
|
||||||
overlay = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT), pygame.SRCALPHA)
|
overlay = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT), pygame.SRCALPHA)
|
||||||
|
|
@ -104,6 +107,15 @@ def draw_end_screen(screen, final_score, high_score):
|
||||||
font_med = pygame.font.Font(None, 60)
|
font_med = pygame.font.Font(None, 60)
|
||||||
font_small = pygame.font.Font(None, 40)
|
font_small = pygame.font.Font(None, 40)
|
||||||
|
|
||||||
|
# "GAME OVER" uzraksts
|
||||||
|
title = font_big.render("Spēle Beigusies", True, (220, 50, 50))
|
||||||
|
screen.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 160)))
|
||||||
|
|
||||||
|
# Beigu punktu skaits
|
||||||
|
score_text = font_med.render(f"Score: {final_score}", True, (255, 255, 255))
|
||||||
|
screen.blit(score_text, score_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 60)))
|
||||||
|
|
||||||
|
# Labākais punktu skaits
|
||||||
# "GAME OVER" title
|
# "GAME OVER" title
|
||||||
title = font_big.render("GAME OVER", True, (220, 50, 50))
|
title = font_big.render("GAME OVER", True, (220, 50, 50))
|
||||||
screen.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 160)))
|
screen.blit(title, title.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 - 160)))
|
||||||
|
|
@ -118,15 +130,14 @@ def draw_end_screen(screen, final_score, high_score):
|
||||||
hs_text = font_med.render(hs_label, True, hs_color)
|
hs_text = font_med.render(hs_label, True, hs_color)
|
||||||
screen.blit(hs_text, hs_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 10)))
|
screen.blit(hs_text, hs_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 10)))
|
||||||
|
|
||||||
# Instructions
|
# Instrukcijas lietotājam
|
||||||
restart_text = font_small.render("Press R to Restart", True, (100, 255, 100))
|
restart_text = font_small.render("Uzspiediet R lai sāktu no jauna", True, (100, 255, 100))
|
||||||
quit_text = font_small.render("Press Q to Quit", True, (255, 100, 100))
|
quit_text = font_small.render("Uzspiediet Q lai izietu", True, (255, 100, 100))
|
||||||
screen.blit(restart_text, restart_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 90)))
|
screen.blit(restart_text, restart_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 90)))
|
||||||
screen.blit(quit_text, quit_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 140)))
|
screen.blit(quit_text, quit_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 140)))
|
||||||
|
|
||||||
|
|
||||||
def reset_game(player, enemies):
|
def reset_game(player, enemies):
|
||||||
"""Reset all game state for a new run."""
|
|
||||||
player.reset()
|
player.reset()
|
||||||
enemies.empty()
|
enemies.empty()
|
||||||
pygame.time.set_timer(SPAWN_FIRST, 1500)
|
pygame.time.set_timer(SPAWN_FIRST, 1500)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue