-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (39 loc) · 1.5 KB
/
main.py
File metadata and controls
54 lines (39 loc) · 1.5 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pygame
import os
from game import Game
base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
screen_width = 600
screen_height = 500
pygame.init()
pygame.mixer.init()
screen = pygame.display.set_mode((screen_width, screen_height))
pygame.display.set_caption("World Of Guessing Numbers! V.1")
icon = pygame.image.load("assets/image/icon_image.png")
pygame.display.set_icon(icon)
pygame.mixer.music.load("assets/sound/background_music.mp3")
pygame.mixer.music.play(-1)
background_image = pygame.image.load("assets/image/background_image.jpg").convert()
number_images = [pygame.image.load(os.path.join('assets', 'image', f"number_{i}.png")).convert_alpha()
for i in range(1, 11)]
class Main:
def __init__(self):
pygame.init()
pygame.mixer.init()
self.screen_width = 600
self.screen_height = 600
self.screen = pygame.display.set_mode((self.screen_width, self.screen_height))
self.game = Game(self.screen_width, self.screen_height)
def run(self):
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
self.game.handle_events(event)
self.game.handle_button_clicks(event)
self.game.draw(self.screen)
pygame.display.flip()
pygame.quit()
if __name__ == "__main__":
main = Main()
main.run()