Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/start.py
diff options
context:
space:
mode:
Diffstat (limited to 'start.py')
-rwxr-xr-xstart.py144
1 files changed, 141 insertions, 3 deletions
diff --git a/start.py b/start.py
index 5a29645..674430f 100755
--- a/start.py
+++ b/start.py
@@ -1,6 +1,144 @@
-import tower
+import tower, levelone, leveltwo, levelthree, levelfour, levelfive, race, util
+import random, os.path
+import util
+
+import pygame
+import pygame.font
+
+from pygame.locals import *
+
+def run():
+ #Must initialize pygame before doing anything else
+ pygame.init()
+ random.seed()
+
+ display_flags = DOUBLEBUF
+
+ #XO laptop is 1200x900 resolution
+ width, height = 1200, 900
+
+ if pygame.display.mode_ok((width, height), display_flags ):
+ screen = pygame.display.set_mode((width, height), display_flags)
+
+ clock = pygame.time.Clock()
+ run = 1
+ pygame.display.set_caption('Math Quest')
+
+ clicked = 0
+ menuLocation = 0 #The variable representing which screen of the main menu the player is on - 0 is the main menu
+
+ mouseRect = pygame.Rect(pygame.mouse.get_pos(),(5,5))
+
+ #Code to set up the initial screen (Stores as surface)
+ mainButtons = [pygame.Rect(400,300,400,100),pygame.Rect(400,450,400,100),pygame.Rect(400,600,400,100)]
+ mainButtonText = ["Start Game","Level Select","Exit"]
+
+ mainScreen = pygame.Surface((width,height))
+
+ for i in range(len(mainButtons)):
+ titleFont = pygame.font.Font(None, 150)
+
+ mainScreen.blit(titleFont.render("Math Quest",1,(250,250,250)),(300,100))
+
+ pygame.draw.rect(mainScreen,[175,0,0],mainButtons[i])
+
+ font = pygame.font.Font(None, 80)
+
+ displayBox = font.render(mainButtonText[i], 1, (255,255,255))
+ textSize = font.size(mainButtonText[i])
+
+ mainScreen.blit(displayBox,(mainButtons[i].topleft[0]+(400-textSize[0])/2,mainButtons[i].topleft[1]+(100-textSize[1])/2))
+
+ #Set up the level select screen (Also stores as surface)
+ levelSelectButtons = [pygame.Rect(175,150,400,100),pygame.Rect(625,150,400,100),pygame.Rect(175,300,400,100),pygame.Rect(625,300,400,100),pygame.Rect(175,450,400,100),pygame.Rect(625,450,400,100),pygame.Rect(175,600,400,100),pygame.Rect(625,600,400,100),pygame.Rect(175,750,850,100)]
+ levelSelectButtonText = ["Bridge Builder","Map","Dungeon","Watch","Race","Tower Gates","Tower Climber","Boss","Back"]
+
+ levelSelectScreen = pygame.Surface((width,height))
+
+ for i in range(len(levelSelectButtons)):
+ titleFont = pygame.font.Font(None, 120)
+
+ levelSelectScreen.blit(titleFont.render("Level Select",1,(250,250,250)),(325,35))
+
+ pygame.draw.rect(levelSelectScreen,[175,0,0],levelSelectButtons[i])
+
+ font = pygame.font.Font(None, 80)
+
+ displayBox = font.render(levelSelectButtonText[i], 1, (255,255,255))
+ textSize = font.size(levelSelectButtonText[i])
+
+ levelSelectScreen.blit(displayBox,(levelSelectButtons[i].topleft[0]+(levelSelectButtons[i].width-textSize[0])/2,levelSelectButtons[i].topleft[1]+(100-textSize[1])/2))
+
+ screen.blit(mainScreen,(0,0))
+ pygame.display.flip()
+
+ while run:
+
+ mouseRect = pygame.Rect(pygame.mouse.get_pos(),(5,5))
+
+ events = pygame.event.get()
+ for event in events:
+ #User decides to exit program
+ if event.type == QUIT:
+ run = 0 #stop running
+
+ if event.type == pygame.MOUSEBUTTONDOWN:
+ clicked = 1
+
+ if clicked == 1:
+ clicked = 0
+ print "Mouse clicked"
+ if menuLocation == 0: #On the main screen
+ clickedButton = mouseRect.collidelist(mainButtons)
+ if clickedButton != -1:
+ print "Button %d clicked"%(clickedButton)
+ if clickedButton == 0:
+ levelone.run()
+ levelfour.run()
+ leveltwo.run()
+ levelthree.run()
+ tower.run()
+ elif clickedButton == 1:
+ menuLocation = 1
+ screen.blit(levelSelectScreen,(0,0))
+ elif clickedButton == 2:
+ run = 0
+ elif menuLocation == 1: #On the level select screen
+ clickedButton = mouseRect.collidelist(levelSelectButtons)
+ if clickedButton != -1:
+ print "Button %d clicked"%(clickedButton)
+ if clickedButton == 0:
+ levelone.run()
+ if clickedButton == 1:
+ leveltwo.run()
+ if clickedButton == 2:
+ levelfive.run()
+ if clickedButton == 3:
+ levelfour.run()
+ if clickedButton == 4:
+ race.run()
+ if clickedButton == 5:
+ levelthree.run()
+ if clickedButton == 6:
+ tower.run()
+ if clickedButton == 7:
+ pass
+ if clickedButton == 8:
+ menuLocation = 0
+ screen.blit(mainScreen,(0,0))
+ pygame.display.flip()
+
+ clock.tick(40) #limits to 40 FPS
+
+ pygame.quit()
+
def main():
- tower.run()
+ run()
+ # levelone.run()
+ # levelfour.run()
+ # leveltwo.run()
+ # levelthree.run()
+ # tower.run()
-if __name__ == '__main__': main() \ No newline at end of file
+if __name__ == '__main__': main()