-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (38 loc) · 1.17 KB
/
main.py
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
# Misc system stuff
import os
import sys
# Pygame
import pygame
from pygame.locals import *
# Game specific
import src.shared as shared
import src.menu as menu
import src.game as game
import src.menuGraphics as menuGraphics
import src.background as background
import src.character as character
import src.obstacles as obstacles
pygame.init()
pygame.mixer.init(48000)
pygame.event.set_allowed([QUIT, KEYDOWN, KEYUP])
# Fix for when game is launched with wrong cwd
if (sys.argv[0].startswith('/')) :
os.chdir(os.path.dirname(sys.argv[0]))
def main() :
shared.score = 0
hsfile = open("highscore.txt", "r+")
hs = hsfile.read()
hsfile.close()
shared.highscore = int(hs.strip())
shared.game = menu.Menu()
shared.loadAssets()
shared.menuGraphics = menuGraphics.MenuGraphics()
shared.background = background.Background()
shared.character = character.Character()
shared.obstacles = obstacles.Obstacles()
while True :
shared.game.mainLoop()
nextScene = shared.game.getNextScene()
if nextScene == "game": shared.game = game.Game()
elif nextScene == "menu": shared.game = menu.Menu()
main()