-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.py
More file actions
32 lines (26 loc) · 1.3 KB
/
Menu.py
File metadata and controls
32 lines (26 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pygame
from States import State
class Main_Menu:
def __init__(self, game):
self.bg = pygame.image.load('Assets/background.png').convert_alpha()
self.game = game
self.max_score = game.max_score
self.font1 = pygame.font.Font('fonts/Jersey10-Regular.ttf', 150)
self.font2 = pygame.font.Font('fonts/Jersey10-Regular.ttf', 70)
self.font3 = pygame.font.Font('fonts/Jersey10-Regular.ttf', 50)
self.text_game_name = self.font1.render('SPACE INVADERS', False, 'White')
self.text_max_score = self.font2.render(f'MAX SCORE {self.max_score}', False, 'White')
self.text_gameplay = self.font3.render('push ENTER to start game', False, 'White')
self.text_redactor = self.font3.render('push SPACE to edit level', False, 'White')
def draw_objects(self, screen):
screen.blit(self.bg, (0, 0))
screen.blit(self.text_game_name, (90, 170))
screen.blit(self.text_max_score, (90, 350))
screen.blit(self.text_gameplay, (270, 500))
screen.blit(self.text_redactor, (300, 600))
def update(self):
keys = pygame.key.get_pressed()
if keys[pygame.K_RETURN]:
self.game.change_state(State.Gameplay)
elif keys[pygame.K_SPACE]:
self.game.change_state(State.Level_redactor)