annotate gamelib/main.py @ 266:381fa22d217b

Fix width / height confusion buglet
author Neil Muller <drnlmuller@gmail.com>
date Sun, 15 Dec 2013 11:43:17 +0200
parents 75033f790e7d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
1 '''Game main module.
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
2
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
3 Contains the entry point used by the run_game.py script.
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
4
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
5 Feel free to put all your game code here, or in other modules in this "gamelib"
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
6 package.
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
7 '''
37
9c4bf1f15431 gui stuff
Rizmari Versfeld <rizziepit@gmail.com>
parents: 1
diff changeset
8 import pygame
61
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
9 import optparse
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
10 import sys
0
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
11
53
655a6912e0ae Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents: 52
diff changeset
12 from gamelib.engine import Engine
163
80cce62f29fb Add placeholder icons for now
Neil Muller <drnlmuller@gmail.com>
parents: 88
diff changeset
13 from gamelib.data import load_image
53
655a6912e0ae Split gui stuff out of main.py
Neil Muller <drnlmuller@gmail.com>
parents: 52
diff changeset
14 from gamelib.mainmenu import MainMenu
52
1d3d20bdc8b9 Move engine stuff into it's own file
Neil Muller <drnlmuller@gmail.com>
parents: 51
diff changeset
15
232
75033f790e7d Remove hooks for sound support - we can add them back easily enough later
Neil Muller <drnlmuller@gmail.com>
parents: 163
diff changeset
16 from gamelib.constants import SCREEN, WINDOW_ICON
0
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
17
1
c90a6586cd66 PEP8-ify skellington (because)
Neil Muller <drnlmuller@gmail.com>
parents: 0
diff changeset
18
61
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
19 def parse_args(args):
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
20 parser = optparse.OptionParser()
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
21
88
74ce25ec2073 Autosave & load support
Neil Muller <drnlmuller@gmail.com>
parents: 61
diff changeset
22 parser.add_option('--load', type="string", default=None,
74ce25ec2073 Autosave & load support
Neil Muller <drnlmuller@gmail.com>
parents: 61
diff changeset
23 dest="load", help="Save game to load")
74ce25ec2073 Autosave & load support
Neil Muller <drnlmuller@gmail.com>
parents: 61
diff changeset
24
61
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
25 return parser.parse_args(args)
37
9c4bf1f15431 gui stuff
Rizmari Versfeld <rizziepit@gmail.com>
parents: 1
diff changeset
26
51
ac637e84f8f8 Consilidate engine stuff and eventify window stack manipulation
Neil Muller <drnlmuller@gmail.com>
parents: 48
diff changeset
27
0
d0de8832774b Import skellington-1.9 into the repo
Neil Muller <drnlmuller+bitbucket@gmail.com>
parents:
diff changeset
28 def main():
61
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
29 opts, args = parse_args(sys.argv)
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
30 pygame.display.init()
a253fae32a6f Add no-sound option (slow shutdown bug workaround)
Neil Muller <drnlmuller@gmail.com>
parents: 53
diff changeset
31 pygame.font.init()
48
a2980cc9a060 Factor out some constants
Neil Muller <drnlmuller@gmail.com>
parents: 44
diff changeset
32 screen = pygame.display.set_mode(SCREEN)
163
80cce62f29fb Add placeholder icons for now
Neil Muller <drnlmuller@gmail.com>
parents: 88
diff changeset
33 pygame.display.set_icon(load_image(WINDOW_ICON))
51
ac637e84f8f8 Consilidate engine stuff and eventify window stack manipulation
Neil Muller <drnlmuller@gmail.com>
parents: 48
diff changeset
34 engine = Engine(screen)
88
74ce25ec2073 Autosave & load support
Neil Muller <drnlmuller@gmail.com>
parents: 61
diff changeset
35 window = MainMenu(screen, opts.load)
51
ac637e84f8f8 Consilidate engine stuff and eventify window stack manipulation
Neil Muller <drnlmuller@gmail.com>
parents: 48
diff changeset
36 engine.run(window)