Make chess puzzle level (Kasparov to F3) winnable.
[naja.git] / naja / __main__.py
1 import sys
2
3 import pygame
4 import pygame.locals as pgl
5
6 from naja.constants import SCREEN
7 from naja.engine import Engine
8 from naja.sound import sound
9 from naja.options import parse_args, options
10 from naja.resources.loader import Loader
11 from naja.scenes.menu import MenuScene
12 from naja.utils import warp_to_game_state
13
14
15 def main():
16     '''Launch the naja'''
17     parse_args(sys.argv)
18     pygame.display.init()
19     pygame.font.init()
20
21     # set_icon needs to be called before set_mode on some platforms, but we
22     # can't use convert_alpha until we've created a window with set_mode
23     r = Loader('data')
24     r.CONVERT_ALPHA = False
25     if sys.platform == 'darwin':
26         # OSX accepts big icons, but scales up small icons smoothly
27         icon_size = 512
28     elif sys.platform == 'win32':
29         # It's corrupted at any smaller size. And crashes, at larger sizes.
30         icon_size = 32
31     else:
32         icon_size = 24
33     pygame.display.set_icon(
34         r.get_image('robot_%i.png' % icon_size, basedir='icons'))
35
36     pygame.display.set_mode(SCREEN, pgl.SWSURFACE)
37     pygame.display.set_caption('Robolock II')
38     sound.init()
39
40     screen = pygame.display.get_surface()
41     scene = MenuScene(None)
42     engine = Engine(screen, scene, None)
43
44     if options.game_state is not None:
45         warp_to_game_state(options.game_state)
46
47     engine.run()
48
49
50 if __name__ == '__main__':
51     main()