-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
57 lines (47 loc) · 1.51 KB
/
Copy pathmain.py
File metadata and controls
57 lines (47 loc) · 1.51 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
55
56
57
import pygame
from modules.hitobjects import HitObject
from modules.json_import import getBeatmapData
from game import Game
import os
BASE_WIDTH = 512
BASE_HEIGHT = 384
FPS = 60
# Colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BACKGROUND = (WHITE)
pygame.init()
screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN)
clock = pygame.time.Clock()
screen_width, screen_height = screen.get_size()
play_area_width = min(screen_width, int(screen_height * (4 / 3)))
play_area_height = int(play_area_width * (3 / 4))
beatmapPath, beatmapProperties = getBeatmapData()
beatmapDir = os.path.dirname(beatmapPath)
audioFileName = beatmapProperties["general"]["AudioFilename"].strip()
audioDir = f'{beatmapDir}\{audioFileName}'.replace("/", "\\")
music = pygame.mixer.Sound(audioDir)
hitObjectList = []
for i in range(len(beatmapProperties["hitobjects"])):
newHitObject = HitObject(
int(beatmapProperties["hitobjects"][i]['x']),
int(beatmapProperties["hitobjects"][i]['y']),
int(beatmapProperties["hitobjects"][i]['time']),
int(beatmapProperties["hitobjects"][i]['type']),
BASE_HEIGHT,
BASE_WIDTH,
play_area_width,
play_area_height
)
hitObjectList.append(newHitObject)
running = True
game = Game(hitObjectList, music, screen)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
else:
game.handle_event(event)
if game.playing:
game.render()
pygame.display.flip()