root/src/main.py @ 259

Revision 259, 5.6 KB (checked in by mmorton, 2 years ago)
Line 
1'''
2Created on Mar 24, 2012
3
4@author: TechTrek
5'''
6import window
7from globals import *
8import pygame, os, math
9from image import *
10from text import *
11from rectangle import *
12import background
13import top
14import onScreenButton
15import inGameMenu
16import sys
17import description
18import menuEntry
19import map
20import spinner
21from buildables import buildingLUT
22
23
24def Initialize():
25    """
26        Returns the top object with everything fully initialized.
27       
28        input type: none
29        return type: top
30    """
31    # surface
32    screenSurface = pygame.display.set_mode((SCREEN_W,SCREEN_H),RESIZABLE)
33    screenSurface.fill(BLACK)
34   
35   
36    newTop = top.Top(screenSurface)
37   
38    newBackground = background.Background((0,0),True,'background.png')
39   
40    ###########################################################################################################
41   
42       
43    buildPowerDescription = description.Description('power',
44                                                    "This is where the text would go.",
45                                                    pygame.image.load(os.path.abspath(iconDir + "power.png")))
46    buildPowerButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*0),False,buildPowerDescription)
47   
48    buildTransportationDescription = description.Description('transportation',
49                                                    "This is where the text would go.",
50                                                    pygame.image.load(os.path.abspath(iconDir + "transportation.png")))
51    buildTransportationButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*1),False,buildTransportationDescription)
52   
53    buildMaterialDescription = description.Description('material',
54                                                    "This is where the text would go.",
55                                                    pygame.image.load(os.path.abspath(iconDir + "material.png")))
56    buildMaterialButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*2),False,buildMaterialDescription)
57   
58    buildMenu = inGameMenu.InGameMenu((20,20),False,'BUILD EMU','build.png')
59    buildMenu.addWindow(buildPowerButton)
60    buildMenu.addWindow(buildTransportationButton)
61    buildMenu.addWindow(buildMaterialButton)
62   
63    ###########################################################################################################
64   
65    researchPowerSpinner = spinner.Spinner((0,0),False)
66   
67    researchPowerDescription = description.Description('power',
68                                                    "This is where the text would go.",
69                                                    pygame.image.load(os.path.abspath(iconDir + "power.png")))
70    researchPowerButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*0),False,researchPowerDescription)
71    researchPowerButton.addResponse((researchPowerSpinner.toggle,))
72    researchPowerButton.addWindow(researchPowerSpinner)
73
74   
75    researchTransportationDescription = description.Description('transportation',
76                                                    "This is where the text would go.",
77                                                    pygame.image.load(os.path.abspath(iconDir + "transportation.png")))
78    researchTransportationButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*1),False,researchTransportationDescription)
79   
80    researchMaterialDescription = description.Description('material',
81                                                    "This is where the text would go.",
82                                                    pygame.image.load(os.path.abspath(iconDir + "material.png")))
83    researchMaterialButton = menuEntry.MenuEntry((20,100+ENTRY_SHIFT*2),False,researchMaterialDescription)
84
85    researchMenu = inGameMenu.InGameMenu((20,20),False,'RESEARCH EMU','research.png')
86    researchMenu.addWindow(researchPowerButton)
87    researchMenu.addWindow(researchTransportationButton)
88    researchMenu.addWindow(researchMaterialButton)
89   
90    ###########################################################################################################
91
92    researchButton = onScreenButton.OnScreenButton((20 + 169,720), True,'RESEARCH')
93    researchButton.addWindow(researchMenu)   
94    researchButton.addResponse((researchMenu.toggle,))
95    researchButton.addResponse((buildMenu.closeWindow,)) 
96   
97    buildButton = onScreenButton.OnScreenButton((20,720),True,'BUILD')
98    buildButton.addWindow(buildMenu)   
99    buildButton.addResponse((buildMenu.toggle,))
100    buildButton.addResponse((researchMenu.closeWindow,))
101   
102    undoButton = onScreenButton.OnScreenButton((20 + 169*2,720), True,'UNDO TURN')
103   
104    newMap = map.Map((600,20),True)
105   
106    ############################################################################################
107   
108    newTop.addWindow(buildButton)
109    newTop.addWindow(researchButton)
110    newTop.addWindow(undoButton)
111    newTop.addWindow(newMap)
112   
113    newTop.addWindow(newBackground)
114   
115    ############################################################################################
116   
117    newTop.event(pygame.event.Event(VIDEORESIZE, {'w':SCREEN_W, 'h':SCREEN_H}))
118    newTop.render(screenSurface)
119    pygame.display.update()
120    return newTop
121
122if __name__ == '__main__':
123    # initialize pygame modules
124    pygame.init()
125    if not pygame.display.get_init():
126        print "Display Error"
127        pygame.quit()
128        sys.exit()
129       
130    # initialize our game   
131    top = Initialize()
132       
133    # run our game!
134    while True:
135        for e in pygame.event.get():
136            top.event(e)
137
138
139
140   
141   
Note: See TracBrowser for help on using the browser.