Initial commit from version 1e-99
[beatscape.git] / beatscape.py
1 #!/usr/bin/python
2 # beatscape is the mother of all musical button games.
3
4 import sys
5 import pygame
6 from keygraph import *
7 from keyfile import *
8 from bmevent import *
9 from chanman import *
10 from formats import *
11 from keyhandler import *
12 import game
13
14 try:
15         import config
16 except ImportError:
17         print "Could not parse config.py. Maybe you forgot a semicolon? :-P"
18         exit(1)
19
20 song = ''
21
22 if len(sys.argv) > 1:
23         song = sys.argv[1]
24
25 try:
26         import psyco
27         print "w00t! going psyco!"
28         psyco.full()
29 except ImportError:
30         pass
31
32 pygame.mixer.pre_init(44100, -16, True, 1)
33 pygame.init()
34 opts = pygame.FULLSCREEN | pygame.DOUBLEBUF | pygame.HWSURFACE
35 pygame.display.set_mode((640,480), opts)
36 screen = pygame.display.get_surface()
37
38 for n in range(0,pygame.joystick.get_count()):
39         pygame.joystick.Joystick(n).init();
40
41 if song:
42         # For now, assume IIDX. We'll make this smarter later.
43         game.playgame(gametypes['IIDX'],song)
44         exit(0)
45
46 from mainmenu import *
47 from fileselect import *
48
49 l = ['mainmenu']
50
51 while 1:
52         obj = None
53
54         if l[0] == 'mainmenu':
55                 obj = MainMenu()
56         elif l[0] == 'fileselect':
57                 obj = FileSelect()
58         elif l[0] == 'play':
59                 obj = game.Game(l[1])
60         elif l[0] == 'quit':
61                 sys.exit(0)
62
63         l = obj.run()
64         # Flush events before switching to the next mode
65         pygame.event.clear()
66
67 pygame.quit()