-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.py
More file actions
31 lines (25 loc) · 1.1 KB
/
Main.py
File metadata and controls
31 lines (25 loc) · 1.1 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
import pygame
import json
from GameLogic import Game
from States import State
def main():
game = Game()
game.gamelogic.change_state(State.Menu)
running = True
while running:
game.gamelogic.current_state.draw_objects(game.screen)
game.gamelogic.current_state.update()
pygame.display.update()
game.clock.tick(game.fps)
for event in pygame.event.get():
if event.type == pygame.QUIT:
with open("files\\maxscore.json", "w", encoding="utf-8") as file:
json.dump(game.gamelogic.max_score, file, ensure_ascii=False, indent=4)
with open("files\\enemies.json", "w", encoding="utf-8") as file:
json.dump([enemy.to_dict() for enemy in game.gamelogic.enemies], file, ensure_ascii=False, indent=4)
with open("files\\blocks.json", "w", encoding="utf-8") as file:
json.dump([block.to_dict() for block in game.gamelogic.blocks], file, ensure_ascii=False, indent=4)
running = False
pygame.quit()
if __name__ == '__main__':
main()