Advertisement
bha2597

Pygame

Jul 25th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 35.50 KB | None | 0 0
  1. import pygame, sys, os, random, shelve, time, sipack
  2. from pygame.locals import *
  3.  
  4.  
  5. pygame.init()
  6.  
  7. def Timer():
  8.     s = 0
  9.     while s<=60:
  10.        
  11.         time.sleep(1)
  12.         s+=1
  13.         print(s)
  14.  
  15. def quitGame():
  16.     pygame.quit()
  17.     sys.exit()
  18.  
  19. def main():
  20.     background_image = pygame.image.load("invoker.png")
  21.     #os.environ['SDL_VIDEO_CENTERED'] = '1'
  22.    
  23.     WIN_WIDTH, WIN_HEIGHT = 1440, 885
  24.     canvas = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT), pygame.FULLSCREEN)
  25.     pygame.display.set_caption("Invoker Game!")
  26.     canvas.blit(background_image, [0,0])
  27.     # Game states
  28.     GAMESTATE_MAINMENU = 0
  29.     GAMESTATE_INGAME = 1
  30.     GAMESTATE_TUTORIAL = 2
  31.     GAMESTATE_OPTIONS = 3
  32.     GAMESTATE_CREDITS = 4
  33.     GAMESTATE_END = 5
  34.    
  35.     gameState = GAMESTATE_MAINMENU
  36.    
  37.  
  38.     # Define the colors in RGB format
  39.     BLACK = pygame.Color(0,0,0)    
  40.     WHITE = pygame.Color(255,255,255)
  41.     QUAS = pygame.Color(93,188,210)
  42.     WEX = pygame.Color(255,0,254)
  43.     EXORT = pygame.Color(254,75,0)
  44.     color1 = WHITE
  45.     color2 = WHITE
  46.     color3 = WHITE
  47.     spell = random.randint(1,10)
  48.     spellText =""
  49.    
  50.     MENUCLICKEDEVENT = USEREVENT + 1 #??
  51.     SHOWSCOREEVENT = USEREVENT + 2
  52.    
  53.     gameMenu = ("Start Game" ,
  54.                 "Tutorial",
  55.                 "Quit")
  56.  
  57.     fontSize = 36
  58.     fontSpace = 4
  59.    
  60.     font = pygame.font.Font(None, fontSize)  
  61.     fontHue = pygame.font.Font(None, fontSize + 30)  
  62.     correctSpell = 0
  63.    
  64.    
  65.     #Image
  66.     coldSnapImage = pygame.image.load("img_cold_snap.png").convert()
  67.     ghostWalkImage = pygame.image.load("img_ghost_walk.png").convert()
  68.     iceWallImage = pygame.image.load("img_ice_wall.png").convert()
  69.     tornadoImage = pygame.image.load("img_tornado.png").convert()
  70.     deafeningBlastImage = pygame.image.load("img_deafening_blast.png").convert()
  71.     forgeSpiritImage = pygame.image.load("img_forge_spirit.png").convert()
  72.     empImage = pygame.image.load("img_emp.png").convert()
  73.     alacrityImage = pygame.image.load("img_alacrity.png").convert()
  74.     chaosMeteorImage = pygame.image.load("img_chaos_meteor.png").convert()
  75.     sunStrikeImage = pygame.image.load("img_sun_strike.png").convert()
  76.     tutorial = pygame.image.load("tutorial.jpg").convert()
  77.     cheatImage = pygame.image.load("cheat.jpg").convert()
  78.     blackSquare = pygame.image.load("img_black_square.png").convert()
  79.     dotaBackground = pygame.image.load("endBack.png").convert()
  80.     blackSquare.set_colorkey(BLACK)
  81.  
  82.    
  83.     soundNum = 0
  84.     cheat = False
  85.  
  86.     oldSpell = 0
  87.     oldSpellName ="No spells casted."
  88.     timeInSec = int(round(time.time()))
  89.    
  90.         # Main game loop
  91.  
  92.    
  93.  
  94.     while True:
  95.         pygame.event.pump()
  96.         for event in pygame.event.get():
  97.             if event.type == QUIT:
  98.                 pygame.quit()
  99.                 sys.exit()
  100.             if event.type == KEYDOWN:
  101.                 color3 = color2
  102.                 color2 = color1
  103.                 if event.key == K_ESCAPE:
  104.                     main()
  105.                 if event.key == K_q:
  106.                     color1 = QUAS
  107.                 if event.key == K_w:
  108.                     color1 = WEX
  109.                 if event.key == K_e:
  110.                     color1 = EXORT
  111.                 if event.key == K_TAB:
  112.                     if cheat:
  113.                         cheat = False
  114.                     else:
  115.                         cheat = True
  116.                 if event.key == K_t:
  117.                     correctSpell += 322
  118.            
  119.                
  120.  
  121.                        
  122.             if event.type == MOUSEBUTTONDOWN:
  123.                 if gameState == GAMESTATE_MAINMENU:
  124.                     eventX = event.pos[0]
  125.                     eventY = event.pos[1]  
  126.                    
  127.                     for i, textPos in enumerate(listOfTextPositions):
  128.                         if textPos.left < eventX < textPos.right and textPos.top < eventY < textPos.bottom:
  129.                             menuEvent = pygame.event.Event(MENUCLICKEDEVENT, item=i, text=gameMenu[i])
  130.                             pygame.event.post(menuEvent)
  131.  
  132.             elif event.type == MENUCLICKEDEVENT:
  133.                 if event.text == "Start Game":
  134.                     gameState = GAMESTATE_INGAME
  135.                 elif event.text == "Quit":
  136.                     quitGame()
  137.                 elif event.text == "Tutorial":
  138.                     gameState = GAMESTATE_TUTORIAL    
  139.             elif event.type == SHOWSCOREEVENT:
  140.                 main()
  141.                
  142.  
  143.                                
  144.         if gameState == GAMESTATE_MAINMENU:
  145.                
  146.             canvas.blit(background_image, [0,0])
  147.             menuHeight = (fontSize + fontSpace) * len(gameMenu)
  148.             startY = canvas.get_height() / 2 - menuHeight / 2
  149.            
  150.             listOfTextPositions = list()
  151.            
  152.             for menuEntry in gameMenu:
  153.                 text = font.render(menuEntry, 1, (250, 250, 250))
  154.                 textPos = text.get_rect(centerx=canvas.get_width() / 2, centery=startY + fontSize + fontSpace + 150)
  155.                
  156.                    
  157.                 listOfTextPositions.append(textPos)
  158.                
  159.                          
  160.                 startY = startY + fontSize + fontSpace
  161.                          
  162.                 canvas.blit(text, textPos)
  163.         elif gameState == GAMESTATE_TUTORIAL:
  164.             canvas.blit(dotaBackground, [0,0])
  165.             canvas.blit(tutorial, [450,100])
  166.             textSurface4 = font.render("Esc to go back", 1, WHITE)
  167.             canvas.blit(textSurface4, (5,5))
  168.                    
  169.         elif gameState == GAMESTATE_END:
  170.             canvas.fill(BLACK)
  171.             canvas.blit(dotaBackground, [0,0])
  172.             TextSurfaceScore = fontHue.render("Your score was: %s" %(str(correctSpell)),1,WHITE)
  173.             canvas.blit(TextSurfaceScore, (100,50))
  174.             TextSurfaceEsc = font.render("Press ESC to go back",1,WHITE)
  175.             canvas.blit(TextSurfaceEsc, (100,750))
  176.             TextSurfaceValve = font.render("Copyright 2011 Valve Corporation",1,WHITE)
  177.             canvas.blit(TextSurfaceValve, (100,660))
  178.             TextSurfaceCopy = font.render("Dota, Dota 2, and Invoker are registered trademarks of Valve Corporation",1,WHITE)
  179.             canvas.blit(TextSurfaceCopy, (100,700))
  180.  
  181.             if correctSpell < 14:
  182.                 rank = "Noob"
  183.             elif correctSpell >= 14 and correctSpell < 19:
  184.                 rank = "Average"
  185.             elif correctSpell >= 19 and correctSpell < 300:
  186.                 rank = "Grand Magus"
  187.             else:
  188.                 rank = "Solo 322 Kappa"
  189.             #sipack.tweet("Hello world.")
  190.             #Crash here
  191.  
  192.             TextSurfaceNoob = fontHue.render("Your rank: %s"%rank,1,WHITE)
  193.             canvas.blit(TextSurfaceNoob, (100,135))
  194.        
  195.             pygame.time.set_timer(SHOWSCOREEVENT, 10000)
  196.         elif gameState == GAMESTATE_INGAME:
  197.             canvas.fill(BLACK)
  198.             timeInSecLoop = int(round(time.time()))    
  199.  
  200.             if timeInSecLoop - timeInSec >= 20:
  201.                 gameState = GAMESTATE_END
  202.        
  203.  
  204.             pygame.draw.circle(canvas, color1, (450, 400), 40, 0)
  205.             pygame.draw.circle(canvas, color2, (700, 400), 40, 0)
  206.             pygame.draw.circle(canvas, color3, (950, 400), 40, 0)
  207.             keys = pygame.key.get_pressed()
  208.  
  209.            
  210.             if spell == 1:
  211.                 spellText = "Cold Snap"
  212.                 canvas.blit(coldSnapImage, [821,500])
  213.                 if color1 == QUAS:
  214.                     if color2 == QUAS:
  215.                         if color3 == QUAS:
  216.                             soundNum = random.randint(1,3)
  217.                             if soundNum ==1:
  218.                                 pygame.mixer.music.load("Invo_ability_coldsnap_01.mp3")
  219.                             elif soundNum ==2:
  220.                                 pygame.mixer.music.load("Invo_ability_coldsnap_02.mp3")
  221.                             else:
  222.                                 pygame.mixer.music.load("Invo_ability_coldsnap_03.mp3")
  223.                             pygame.mixer.music.play(0)
  224.                             oldSpell = spell
  225.                             spell = random.randint(1,10)
  226.                             correctSpell +=1
  227.  
  228.            
  229.            
  230.             elif spell == 2:
  231.                 spellText = "Ghost Walk"
  232.                 canvas.blit(ghostWalkImage, [821,500])
  233.                 if color1 == QUAS:
  234.                     if color2 == QUAS:
  235.                         if color3 == WEX:
  236.                             soundNum = random.randint(1,3)
  237.                             if soundNum ==1:
  238.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_01.mp3")
  239.                             elif soundNum ==2:
  240.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_02.mp3")
  241.                             else:
  242.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_03.mp3")
  243.                             pygame.mixer.music.play(0)
  244.                             oldSpell = spell
  245.                             spell = random.randint(1,10)
  246.                             correctSpell +=1
  247.                            
  248.  
  249.                 if color2 == WEX:
  250.                     if color3 == QUAS:
  251.                         if color1 == QUAS:
  252.                             soundNum = random.randint(1,3)
  253.                             if soundNum ==1:
  254.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_01.mp3")
  255.                             elif soundNum ==2:
  256.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_02.mp3")
  257.                             else:
  258.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_03.mp3")
  259.                             pygame.mixer.music.play(0)
  260.                             oldSpell = spell
  261.                             spell = random.randint(1,10)
  262.                             correctSpell +=1
  263.            
  264.                 if color1 == WEX:
  265.                     if color2 == QUAS:
  266.                         if color3 == QUAS:
  267.                             soundNum = random.randint(1,3)
  268.                             if soundNum ==1:
  269.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_01.mp3")
  270.                             elif soundNum ==2:
  271.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_02.mp3")
  272.                             else:
  273.                                 pygame.mixer.music.load("Invo_ability_ghostwalk_03.mp3")
  274.                             pygame.mixer.music.play(0)
  275.                             oldSpell = spell
  276.                             spell = random.randint(1,10)
  277.                             correctSpell +=1
  278.                            
  279.             elif spell == 3:
  280.                 spellText = "Ice Wall"
  281.                 canvas.blit(iceWallImage, [821,500])
  282.                 if color1 == EXORT:
  283.                     if color2 == QUAS:
  284.                         if color3 == QUAS:
  285.                    
  286.                             soundNum = random.randint(1,3)
  287.                             if soundNum ==1:
  288.                                 pygame.mixer.music.load("Invo_ability_icewall_01.mp3")
  289.                             elif soundNum ==2:
  290.                                 pygame.mixer.music.load("Invo_ability_icewall_02.mp3")
  291.                             else:
  292.                                 pygame.mixer.music.load("Invo_ability_icewall_03.mp3")
  293.                             pygame.mixer.music.play(0)
  294.                             oldSpell = spell
  295.                             spell = random.randint(1,10)
  296.                             correctSpell +=1
  297.                          
  298.                 elif color1 == QUAS:
  299.                     if color2 == EXORT:
  300.                         if color3 == QUAS:
  301.                
  302.                             soundNum = random.randint(1,3)
  303.                             if soundNum ==1:
  304.                                 pygame.mixer.music.load("Invo_ability_icewall_01.mp3")
  305.                             elif soundNum ==2:
  306.                                 pygame.mixer.music.load("Invo_ability_icewall_02.mp3")
  307.                             else:
  308.                                 pygame.mixer.music.load("Invo_ability_icewall_03.mp3")
  309.                             pygame.mixer.music.play(0)
  310.                             oldSpell = spell
  311.                             spell = random.randint(1,10)
  312.                             correctSpell +=1
  313.                                
  314.                     elif color2 == QUAS:
  315.                         if color3 == EXORT:
  316.                            
  317.                             soundNum = random.randint(1,3)
  318.                             if soundNum ==1:
  319.                                 pygame.mixer.music.load("Invo_ability_icewall_01.mp3")
  320.                             elif soundNum ==2:
  321.                                 pygame.mixer.music.load("Invo_ability_icewall_02.mp3")
  322.                             else:
  323.                                 pygame.mixer.music.load("Invo_ability_icewall_03.mp3")
  324.                             pygame.mixer.music.play(0)
  325.                             oldSpell = spell
  326.                             spell = random.randint(1,10)
  327.                             correctSpell +=1
  328.                                
  329.             elif spell == 4:
  330.                 canvas.blit(tornadoImage, [821,500])
  331.                 spellText = "Tornado"
  332.                 if color1 == QUAS:
  333.                     if color2 == WEX:
  334.                         if color3 == WEX:
  335.                            
  336.                             soundNum = random.randint(1,3)
  337.                             if soundNum ==1:
  338.                                 pygame.mixer.music.load("Invo_ability_tornado_01.mp3")
  339.                             elif soundNum ==2:
  340.                                 pygame.mixer.music.load("Invo_ability_tornado_02.mp3")
  341.                             else:
  342.                                 pygame.mixer.music.load("Invo_ability_tornado_03.mp3")
  343.                             pygame.mixer.music.play(0)
  344.                             oldSpell = spell
  345.                             spell = random.randint(1,10)
  346.                             correctSpell +=1
  347.                                
  348.                 elif color1 == WEX:
  349.                     if color2 == WEX:
  350.                         if color3 == QUAS:
  351.  
  352.                             soundNum = random.randint(1,3)
  353.                             if soundNum ==1:
  354.                                 pygame.mixer.music.load("Invo_ability_tornado_01.mp3")
  355.                             elif soundNum ==2:
  356.                                 pygame.mixer.music.load("Invo_ability_tornado_02.mp3")
  357.                             else:
  358.                                 pygame.mixer.music.load("Invo_ability_tornado_03.mp3")
  359.                             pygame.mixer.music.play(0)
  360.                             oldSpell = spell
  361.                             spell = random.randint(1,10)
  362.                             correctSpell +=1
  363.                     elif color2 == QUAS:
  364.                         if color3 == WEX:
  365.  
  366.                             soundNum = random.randint(1,3)
  367.                             if soundNum ==1:
  368.                                 pygame.mixer.music.load("Invo_ability_tornado_01.mp3")
  369.                             elif soundNum ==2:
  370.                                 pygame.mixer.music.load("Invo_ability_tornado_02.mp3")
  371.                             else:
  372.                                 pygame.mixer.music.load("Invo_ability_tornado_03.mp3")
  373.                             pygame.mixer.music.play(0)
  374.                             oldSpell = spell
  375.                             spell = random.randint(1,10)
  376.                             correctSpell +=1
  377.                                
  378.             elif spell == 5:
  379.                 spellText = "Deafening Blast"
  380.                 canvas.blit(deafeningBlastImage, [821,500])
  381.                 if color1 == QUAS:
  382.                     if color2 == WEX:
  383.                         if color3 == EXORT:
  384.                            
  385.                             soundNum = random.randint(1,5)
  386.                             if soundNum ==1:
  387.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  388.                             elif soundNum ==2:
  389.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  390.                             elif soundNum ==3:
  391.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  392.                             elif soundNum ==4:
  393.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  394.                             else:
  395.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  396.                             pygame.mixer.music.play(0)
  397.                             oldSpell = spell
  398.                             spell = random.randint(1,10)
  399.                             correctSpell +=1
  400.                                
  401.                     elif color2 == EXORT:
  402.                         if color3 == WEX:
  403.                        
  404.                             soundNum = random.randint(1,5)
  405.                             if soundNum ==1:
  406.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  407.                             elif soundNum ==2:
  408.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  409.                             elif soundNum ==3:
  410.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  411.                             elif soundNum ==4:
  412.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  413.                             elif soundNum ==5:
  414.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  415.                             pygame.mixer.music.play(0)
  416.                             oldSpell = spell
  417.                             spell = random.randint(1,10)
  418.                             correctSpell +=1
  419.                                
  420.                 elif color1 == WEX:
  421.                     if color2 == QUAS:
  422.                         if color3 == EXORT:
  423.                        
  424.                             soundNum = random.randint(1,5)
  425.                             if soundNum ==1:
  426.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  427.                             elif soundNum ==2:
  428.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  429.                             elif soundNum ==3:
  430.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  431.                             elif soundNum ==4:
  432.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  433.                             else:
  434.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  435.                        
  436.                             pygame.mixer.music.play(0)
  437.                             oldSpell = spell
  438.                             spell = random.randint(1,10)
  439.                             correctSpell +=1
  440.                                
  441.                     elif color2 == EXORT:
  442.                         if color3 == QUAS:
  443.                        
  444.                             soundNum = random.randint(1,5)
  445.                             if soundNum ==1:
  446.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  447.                             elif soundNum ==2:
  448.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  449.                             elif soundNum ==3:
  450.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  451.                             elif soundNum ==4:
  452.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  453.                             else:
  454.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  455.                        
  456.                             pygame.mixer.music.play(0)
  457.                             oldSpell = spell
  458.                             spell = random.randint(1,10)
  459.                             correctSpell +=1
  460.  
  461.                                                    
  462.                 elif color1 == EXORT:
  463.                     if color2 == QUAS:
  464.                         if color3 == WEX:
  465.                        
  466.                             soundNum = random.randint(1,5)
  467.                             if soundNum ==1:
  468.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  469.                             elif soundNum ==2:
  470.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  471.                             elif soundNum ==3:
  472.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  473.                             elif soundNum ==4:
  474.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  475.                             elif soundNum ==5:
  476.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  477.                             else:
  478.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_06.mp3")
  479.                             pygame.mixer.music.play(0)
  480.                             oldSpell = spell
  481.                             spell = random.randint(1,10)
  482.                             correctSpell +=1
  483.                                
  484.                     elif color2 == WEX:
  485.                         if color3 == QUAS:
  486.                        
  487.                             soundNum = random.randint(1,5)
  488.                             if soundNum ==1:
  489.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_01.mp3")
  490.                             elif soundNum ==2:
  491.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_02.mp3")
  492.                             elif soundNum ==3:
  493.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_03.mp3")
  494.                             elif soundNum ==4:
  495.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_04.mp3")
  496.                             else:
  497.                                 pygame.mixer.music.load("Invo_ability_deafeningblast_05.mp3")
  498.            
  499.                             pygame.mixer.music.play(0)
  500.                             oldSpell = spell
  501.                             spell = random.randint(1,10)
  502.                             correctSpell +=1
  503.                                
  504.             elif spell == 6:
  505.                 spellText = "Forge Spirits"
  506.                 canvas.blit(forgeSpiritImage, [821,500])
  507.                 if color1 == EXORT:
  508.                     if color2 == EXORT:
  509.                         if color3 == QUAS:
  510.                        
  511.                             soundNum = random.randint(1,3)
  512.                             if soundNum ==1:
  513.                                 pygame.mixer.music.load("Invo_ability_forgespirit_01.mp3")
  514.                             elif soundNum ==2:
  515.                                 pygame.mixer.music.load("Invo_ability_forgespirit_02.mp3")
  516.                             else:
  517.                                 pygame.mixer.music.load("Invo_ability_forgespirit_03.mp3")
  518.                             pygame.mixer.music.play(0)
  519.                             oldSpell = spell
  520.                             spell = random.randint(1,10)
  521.                             correctSpell +=1
  522.                                
  523.                 elif color1 == EXORT:
  524.                     if color2 == QUAS:
  525.                         if color3 == EXORT:
  526.                        
  527.                             soundNum = random.randint(1,3)
  528.                             if soundNum ==1:
  529.                                 pygame.mixer.music.load("Invo_ability_forgespirit_01.mp3")
  530.                             elif soundNum ==2:
  531.                                 pygame.mixer.music.load("Invo_ability_forgespirit_02.mp3")
  532.                             else:
  533.                                 pygame.mixer.music.load("Invo_ability_forgespirit_03.mp3")
  534.                             pygame.mixer.music.play(0)
  535.                             oldSpell = spell
  536.                             spell = random.randint(1,10)
  537.                             correctSpell +=1
  538.                                
  539.                 elif color1 == QUAS:
  540.                     if color2 == EXORT:
  541.                         if color3 == EXORT:
  542.                          
  543.                             soundNum = random.randint(1,3)
  544.                             if soundNum ==1:
  545.                                 pygame.mixer.music.load("Invo_ability_forgespirit_01.mp3")
  546.                             elif soundNum ==2:
  547.                                 pygame.mixer.music.load("Invo_ability_forgespirit_02.mp3")
  548.                             else:
  549.                                 pygame.mixer.music.load("Invo_ability_forgespirit_03.mp3")
  550.                             pygame.mixer.music.play(0)
  551.                             oldSpell = spell
  552.                             spell = random.randint(1,10)
  553.                             correctSpell +=1
  554.                                
  555.             elif spell == 7:
  556.                 spellText = "EMP"
  557.                 canvas.blit(empImage, [821,500])
  558.                 if color1 == WEX:
  559.                     if color2 == WEX:
  560.                         if color3 == WEX:
  561.                        
  562.                             soundNum = random.randint(1,5)
  563.                             if soundNum ==1:
  564.                                 pygame.mixer.music.load("Invo_ability_emp_01.mp3")
  565.                             elif soundNum ==2:
  566.                                 pygame.mixer.music.load("Invo_ability_emp_02.mp3")
  567.                             elif soundNum ==3:
  568.                                 pygame.mixer.music.load("Invo_ability_emp_03.mp3")
  569.                             elif soundNum ==4:
  570.                                 pygame.mixer.music.load("Invo_ability_emp_04.mp3")
  571.                             else:
  572.                                 pygame.mixer.music.load("Invo_ability_emp_05.mp3")
  573.                             pygame.mixer.music.play(0)
  574.                             oldSpell = spell
  575.                             spell = random.randint(1,10)
  576.                             correctSpell +=1
  577.                                
  578.             elif spell == 8:
  579.                 spellText = "Alacrity"
  580.                 canvas.blit(alacrityImage, [821,500])
  581.                 if color1 == WEX:
  582.                     if color2 == WEX:
  583.                         if color3 == EXORT:
  584.                        
  585.                             soundNum = random.randint(1,3)
  586.                             if soundNum ==1:
  587.                                 pygame.mixer.music.load("Invo_ability_alacrity_01.mp3")
  588.                             elif soundNum ==2:
  589.                                 pygame.mixer.music.load("Invo_ability_alacrity_02.mp3")
  590.                             else:
  591.                                 pygame.mixer.music.load("Invo_ability_alacrity_03.mp3")
  592.                             pygame.mixer.music.play(0)
  593.                             oldSpell = spell
  594.                             spell = random.randint(1,10)
  595.                             correctSpell +=1
  596.                                
  597.                 elif color1 == EXORT:
  598.                     if color2 == WEX:
  599.                         if color3 == WEX:
  600.                        
  601.                             soundNum = random.randint(1,3)
  602.                             if soundNum ==1:
  603.                                 pygame.mixer.music.load("Invo_ability_alacrity_01.mp3")
  604.                             elif soundNum ==2:
  605.                                 pygame.mixer.music.load("Invo_ability_alacrity_02.mp3")
  606.                             else:
  607.                                 pygame.mixer.music.load("Invo_ability_alacrity_03.mp3")
  608.                             pygame.mixer.music.play(0)
  609.                             oldSpell = spell
  610.                             spell = random.randint(1,10)
  611.                             correctSpell +=1
  612.                                
  613.                 elif color1 == WEX:
  614.                     if color2 == EXORT:
  615.                         if color3 == WEX:
  616.                            
  617.                             soundNum = random.randint(1,3)
  618.                             if soundNum ==1:
  619.                                 pygame.mixer.music.load("Invo_ability_alacrity_01.mp3")
  620.                             elif soundNum ==2:
  621.                                 pygame.mixer.music.load("Invo_ability_alacrity_02.mp3")
  622.                             else:
  623.                                 pygame.mixer.music.load("Invo_ability_alacrity_03.mp3")
  624.                             pygame.mixer.music.play(0)
  625.                             oldSpell = spell
  626.                             spell = random.randint(1,10)
  627.                             correctSpell +=1
  628.                                
  629.             elif spell == 9:
  630.                 spellText = "Chaos Meteor"
  631.                 canvas.blit(chaosMeteorImage, [821,500])
  632.                 if color1 == EXORT:
  633.                     if color2 == EXORT:
  634.                         if color3 == WEX:
  635.                        
  636.                             soundNum = random.randint(1,4)
  637.                             if soundNum ==1:
  638.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_01.mp3")
  639.                             elif soundNum ==2:
  640.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_02.mp3")
  641.                             elif soundNum ==3:
  642.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_03.mp3")
  643.                             else:
  644.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_04.mp3")
  645.                             pygame.mixer.music.play(0)
  646.                             oldSpell = spell
  647.                             spell = random.randint(1,10)
  648.                             correctSpell +=1
  649.                                
  650.                 elif color1 == EXORT:
  651.                     if color2 == WEX:
  652.                         if color == EXORT:
  653.                        
  654.                             soundNum = random.randint(1,4)
  655.                             if soundNum ==1:
  656.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_01.mp3")
  657.                             elif soundNum ==2:
  658.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_02.mp3")
  659.                             elif soundNum ==3:
  660.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_03.mp3")
  661.                             else:
  662.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_04.mp3")
  663.                             pygame.mixer.music.play(0)
  664.                             oldSpell = spell
  665.                             spell = random.randint(1,10)
  666.                             correctSpell +=1
  667.                                
  668.                 elif color1 == WEX:
  669.                     if color2 == EXORT:
  670.                         if color3 == EXORT:
  671.                        
  672.                             soundNum = random.randint(1,4)
  673.                             if soundNum ==1:
  674.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_01.mp3")
  675.                             elif soundNum ==2:
  676.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_02.mp3")
  677.                             elif soundNum ==3:
  678.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_03.mp3")
  679.                             else:
  680.                                 pygame.mixer.music.load("Invo_ability_chaosmeteor_04.mp3")
  681.                             pygame.mixer.music.play(0)
  682.                             oldSpell = spell
  683.                             spell = random.randint(1,10)
  684.                             correctSpell +=1
  685.                                
  686.             elif spell == 10:
  687.                 spellText = "Sun Strike"
  688.                 canvas.blit(sunStrikeImage, [821,500])
  689.                 if color1 == EXORT:
  690.                     if color2 == EXORT:
  691.                         if color3 ==EXORT:
  692.                             soundNum = random.randint(1,3)
  693.                             if soundNum ==1:
  694.                                 pygame.mixer.music.load("Invo_ability_sunstrike_01.mp3")
  695.                             elif soundNum ==2:
  696.                                 pygame.mixer.music.load("Invo_ability_sunstrike_02.mp3")
  697.                             else:
  698.                                 pygame.mixer.music.load("Invo_ability_sunstrike_03.mp3")
  699.                             pygame.mixer.music.play(0)
  700.                             oldSpell = spell
  701.                             spell = random.randint(1,10)
  702.                             correctSpell +=1
  703.  
  704.                                
  705.             if oldSpell == 0:
  706.                 canvas.blit(blackSquare, [460,500])
  707.             elif oldSpell == 1:
  708.                 canvas.blit(coldSnapImage, [460,500])
  709.                 oldSpellName = "Cold Snap"
  710.             elif oldSpell == 2:
  711.                 canvas.blit(ghostWalkImage, [460,500])
  712.                 oldSpellName = "Ghost Walk"
  713.             elif oldSpell == 3:
  714.                 canvas.blit(iceWallImage, [460,500])
  715.                 oldSpellName = "Ice Wall"
  716.             elif oldSpell == 4:
  717.                 canvas.blit(tornadoImage, [460,500])
  718.                 oldSpellName = "Tornado"
  719.             elif oldSpell == 5:
  720.                 canvas.blit(deafeningBlastImage, [460,500])
  721.                 oldSpellName = "Deafening Blast"
  722.             elif oldSpell == 6:
  723.                 canvas.blit(forgeSpiritImage, [460,500])
  724.                 oldSpellName = "Forge Spirit"
  725.             elif oldSpell == 7:
  726.                 canvas.blit(empImage, [460,500])
  727.                 oldSpellName = "EMP"
  728.             elif oldSpell == 8:
  729.                 canvas.blit(alacrityImage, [460,500])
  730.                 oldSpellName = "Alacrity"
  731.             elif oldSpell == 9:
  732.                 canvas.blit(chaosMeteorImage, [460,500])
  733.                 oldSpellName = "Chaos Meteor"
  734.             else:
  735.                 canvas.blit(sunStrikeImage, [460,500])
  736.                 oldSpellName = "Sun Strike"
  737.  
  738.             hue = timeInSecLoop - timeInSec            
  739.             if cheat:
  740.                 canvas.blit(cheatImage, [25,50])
  741.             else:
  742.                 pygame.draw.rect(canvas, BLACK, (100,100,100,100))
  743.             textSurface1 = font.render("New Spell: %s" %spellText, 1, WHITE)
  744.             canvas.blit(textSurface1, (761, 700))
  745.             textSurface2 = font.render("Correct spells so far: %d" %correctSpell, 1, WHITE)
  746.             canvas.blit(textSurface2, (550, 200))
  747.             textSurface3 = font.render("Click Tab to display cheat sheet",1,WHITE)
  748.             canvas.blit(textSurface3, (15, 15))
  749.             textSurface5 = font.render("Old Spell: %s"%oldSpellName,1,WHITE)
  750.             canvas.blit(textSurface5, (351,700))
  751.             textSurface6 = font.render("Time: %d" %hue,1,WHITE)
  752.             canvas.blit(textSurface6,(WIN_WIDTH/2 - 70,100))
  753.            
  754.            
  755.            
  756.  
  757.  
  758.        
  759.  
  760.  
  761.            
  762.         pygame.display.update()
  763.            
  764.  
  765. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement