Advertisement
thenewboston

[source code] Pygame (Python Game Development) Tutorial 79

Nov 15th, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 19.78 KB | None | 0 0
  1. import pygame
  2. import time
  3. import random
  4.  
  5. pygame.init()
  6.  
  7. display_width = 800
  8. display_height = 600
  9.  
  10. gameDisplay = pygame.display.set_mode((display_width,display_height))
  11.  
  12.  
  13. pygame.display.set_caption('Tanks')
  14.  
  15. #icon = pygame.image.load("apple.png")      
  16. #pygame.display.set_icon(icon)
  17.  
  18. white = (255,255,255)
  19. black = (0,0,0)
  20.  
  21.  
  22. red = (200,0,0)
  23. light_red = (255,0,0)
  24.  
  25. yellow = (200,200,0)
  26. light_yellow = (255,255,0)
  27.  
  28. green = (34,177,76)
  29. light_green = (0,255,0)
  30.  
  31. clock = pygame.time.Clock()
  32.  
  33.  
  34.  
  35.  
  36. tankWidth = 40
  37. tankHeight = 20
  38.  
  39. turretWidth = 5
  40. wheelWidth = 5
  41.  
  42. ground_height = 35
  43.  
  44.  
  45.  
  46.  
  47.  
  48. smallfont = pygame.font.SysFont("comicsansms", 25)
  49. medfont = pygame.font.SysFont("comicsansms", 50)
  50. largefont = pygame.font.SysFont("comicsansms", 85)
  51.  
  52. #img = pygame.image.load('snakehead.png')
  53. #appleimg = pygame.image.load('apple.png')
  54.  
  55. def score(score):
  56.  
  57.     text = smallfont.render("Score: "+str(score), True, black)
  58.     gameDisplay.blit(text, [0,0])
  59.    
  60.  
  61. def text_objects(text, color,size = "small"):
  62.  
  63.     if size == "small":
  64.         textSurface = smallfont.render(text, True, color)
  65.     if size == "medium":
  66.         textSurface = medfont.render(text, True, color)
  67.     if size == "large":
  68.         textSurface = largefont.render(text, True, color)
  69.  
  70.     return textSurface, textSurface.get_rect()
  71.  
  72. def text_to_button(msg, color, buttonx, buttony, buttonwidth, buttonheight, size = "small"):
  73.     textSurf, textRect = text_objects(msg,color,size)
  74.     textRect.center = ((buttonx+(buttonwidth/2)), buttony+(buttonheight/2))
  75.     gameDisplay.blit(textSurf, textRect)
  76.    
  77. def message_to_screen(msg,color, y_displace = 0, size = "small"):
  78.     textSurf, textRect = text_objects(msg,color,size)
  79.     textRect.center = (int(display_width / 2), int(display_height / 2)+y_displace)
  80.     gameDisplay.blit(textSurf, textRect)
  81.  
  82. def tank(x,y,turPos):
  83.     x = int(x)
  84.     y = int(y)
  85.  
  86.  
  87.     possibleTurrets = [(x-27, y-2),
  88.                        (x-26, y-5),
  89.                        (x-25, y-8),
  90.                        (x-23, y-12),
  91.                        (x-20, y-14),
  92.                        (x-18, y-15),
  93.                        (x-15, y-17),
  94.                        (x-13, y-19),
  95.                        (x-11, y-21)
  96.                        ]
  97.  
  98.     pygame.draw.circle(gameDisplay, black, (x,y), int(tankHeight/2))
  99.     pygame.draw.rect(gameDisplay, black, (x-tankHeight, y, tankWidth, tankHeight))
  100.  
  101.     pygame.draw.line(gameDisplay, black, (x,y), possibleTurrets[turPos], turretWidth)
  102.  
  103.     pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
  104.     pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
  105.        
  106.  
  107.     pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
  108.     pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
  109.     pygame.draw.circle(gameDisplay, black, (x-5, y+20), wheelWidth)
  110.     pygame.draw.circle(gameDisplay, black, (x, y+20), wheelWidth)
  111.     pygame.draw.circle(gameDisplay, black, (x+5, y+20), wheelWidth)
  112.     pygame.draw.circle(gameDisplay, black, (x+10, y+20), wheelWidth)
  113.     pygame.draw.circle(gameDisplay, black, (x+15, y+20), wheelWidth)
  114.  
  115.     return possibleTurrets[turPos]
  116.  
  117.  
  118. def enemy_tank(x,y,turPos):
  119.     x = int(x)
  120.     y = int(y)
  121.  
  122.  
  123.     possibleTurrets = [(x+27, y-2),
  124.                        (x+26, y-5),
  125.                        (x+25, y-8),
  126.                        (x+23, y-12),
  127.                        (x+20, y-14),
  128.                        (x+18, y-15),
  129.                        (x+15, y-17),
  130.                        (x+13, y-19),
  131.                        (x+11, y-21)
  132.                        ]
  133.  
  134.     pygame.draw.circle(gameDisplay, black, (x,y), int(tankHeight/2))
  135.     pygame.draw.rect(gameDisplay, black, (x-tankHeight, y, tankWidth, tankHeight))
  136.  
  137.     pygame.draw.line(gameDisplay, black, (x,y), possibleTurrets[turPos], turretWidth)
  138.  
  139.     pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
  140.     pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
  141.        
  142.  
  143.     pygame.draw.circle(gameDisplay, black, (x-15, y+20), wheelWidth)
  144.     pygame.draw.circle(gameDisplay, black, (x-10, y+20), wheelWidth)
  145.     pygame.draw.circle(gameDisplay, black, (x-5, y+20), wheelWidth)
  146.     pygame.draw.circle(gameDisplay, black, (x, y+20), wheelWidth)
  147.     pygame.draw.circle(gameDisplay, black, (x+5, y+20), wheelWidth)
  148.     pygame.draw.circle(gameDisplay, black, (x+10, y+20), wheelWidth)
  149.     pygame.draw.circle(gameDisplay, black, (x+15, y+20), wheelWidth)
  150.  
  151.     return possibleTurrets[turPos]
  152.  
  153.  
  154. def game_controls():
  155.  
  156.  
  157.     gcont = True
  158.  
  159.     while gcont:
  160.         for event in pygame.event.get():
  161.                 #print(event)
  162.                 if event.type == pygame.QUIT:
  163.                     pygame.quit()
  164.                     quit()
  165.  
  166.  
  167.         gameDisplay.fill(white)
  168.         message_to_screen("Controls",green,-100,size="large")
  169.         message_to_screen("Fire: Spacebar",black,-30)
  170.         message_to_screen("Move Turret: Up and Down arrows",black,10)
  171.         message_to_screen("Move Tank: Left and Right arrows",black,50)
  172.         message_to_screen("Pause: P",black,90)
  173.  
  174.  
  175.         button("play", 150,500,100,50, green, light_green, action="play")
  176.         button("Main", 350,500,100,50, yellow, light_yellow, action="main")
  177.         button("quit", 550,500,100,50, red, light_red, action ="quit")
  178.  
  179.  
  180.  
  181.         pygame.display.update()
  182.  
  183.         clock.tick(15)
  184.  
  185.  
  186. def button(text, x, y, width, height, inactive_color, active_color, action = None):
  187.     cur = pygame.mouse.get_pos()
  188.     click = pygame.mouse.get_pressed()
  189.     #print(click)
  190.     if x + width > cur[0] > x and y + height > cur[1] > y:
  191.         pygame.draw.rect(gameDisplay, active_color, (x,y,width,height))
  192.         if click[0] == 1 and action != None:
  193.             if action == "quit":
  194.                 pygame.quit()
  195.                 quit()
  196.  
  197.             if action == "controls":
  198.                 game_controls()
  199.  
  200.             if action == "play":
  201.                 gameLoop()
  202.  
  203.             if action == "main":
  204.                 game_intro()
  205.            
  206.     else:
  207.         pygame.draw.rect(gameDisplay, inactive_color, (x,y,width,height))
  208.  
  209.     text_to_button(text,black,x,y,width,height)
  210.        
  211.  
  212.  
  213. def pause():
  214.  
  215.     paused = True
  216.     message_to_screen("Paused",black,-100,size="large")
  217.     message_to_screen("Press C to continue playing or Q to quit",black,25)
  218.     pygame.display.update()
  219.     while paused:
  220.         for event in pygame.event.get():
  221.                
  222.                 if event.type == pygame.QUIT:
  223.                     pygame.quit()
  224.                     quit()
  225.                 if event.type == pygame.KEYDOWN:
  226.                     if event.key == pygame.K_c:
  227.                         paused = False
  228.                     elif event.key == pygame.K_q:
  229.                         pygame.quit()
  230.                         quit()
  231.  
  232.        
  233.  
  234.         clock.tick(5)
  235.  
  236.  
  237.  
  238. def barrier(xlocation,randomHeight, barrier_width):
  239.    
  240.     pygame.draw.rect(gameDisplay, black, [xlocation, display_height-randomHeight, barrier_width,randomHeight])
  241.    
  242. def explosion(x, y, size=50):
  243.  
  244.     explode = True
  245.  
  246.     while explode:
  247.         for event in pygame.event.get():
  248.             if event.type == pygame.QUIT:
  249.                 pygame.quit()
  250.                 quit()
  251.  
  252.         startPoint = x,y
  253.  
  254.         colorChoices = [red, light_red, yellow, light_yellow]
  255.  
  256.         magnitude = 1
  257.  
  258.         while magnitude < size:
  259.  
  260.             exploding_bit_x = x +random.randrange(-1*magnitude,magnitude)
  261.             exploding_bit_y = y +random.randrange(-1*magnitude,magnitude)
  262.  
  263.             pygame.draw.circle(gameDisplay, colorChoices[random.randrange(0,4)], (exploding_bit_x,exploding_bit_y),random.randrange(1,5))
  264.             magnitude += 1
  265.  
  266.             pygame.display.update()
  267.             clock.tick(100)
  268.  
  269.         explode = False
  270.        
  271.        
  272.  
  273.  
  274. def fireShell(xy,tankx,tanky,turPos,gun_power,xlocation,barrier_width,randomHeight,enemyTankX, enemyTankY):
  275.     fire = True
  276.     damage = 0
  277.  
  278.     startingShell = list(xy)
  279.  
  280.     print("FIRE!",xy)
  281.  
  282.     while fire:
  283.         for event in pygame.event.get():
  284.             if event.type == pygame.QUIT:
  285.                 pygame.quit()
  286.                 quit()
  287.  
  288.         #print(startingShell[0],startingShell[1])
  289.         pygame.draw.circle(gameDisplay, red, (startingShell[0],startingShell[1]),5)
  290.  
  291.  
  292.         startingShell[0] -= (12 - turPos)*2
  293.  
  294.         # y = x**2
  295.         startingShell[1] += int((((startingShell[0]-xy[0])*0.015/(gun_power/50))**2) - (turPos+turPos/(12-turPos)))
  296.  
  297.         if startingShell[1] > display_height-ground_height:
  298.             print("Last shell:",startingShell[0], startingShell[1])
  299.             hit_x = int((startingShell[0]*display_height-ground_height)/startingShell[1])
  300.             hit_y = int(display_height-ground_height)
  301.             print("Impact:", hit_x,hit_y)
  302.            
  303.             if enemyTankX + 15 > hit_x > enemyTankX - 15:
  304.                 print("HIT TARGET!")
  305.                 damage = 25
  306.            
  307.            
  308.             explosion(hit_x,hit_y)
  309.             fire = False
  310.  
  311.         check_x_1 = startingShell[0] <= xlocation + barrier_width
  312.         check_x_2 = startingShell[0] >= xlocation
  313.  
  314.         check_y_1 = startingShell[1] <= display_height
  315.         check_y_2 = startingShell[1] >= display_height - randomHeight
  316.  
  317.         if check_x_1 and check_x_2 and check_y_1 and check_y_2:
  318.             print("Last shell:",startingShell[0], startingShell[1])
  319.             hit_x = int((startingShell[0]))
  320.             hit_y = int(startingShell[1])
  321.             print("Impact:", hit_x,hit_y)
  322.             explosion(hit_x,hit_y)
  323.             fire = False
  324.            
  325.  
  326.         pygame.display.update()
  327.         clock.tick(60)
  328.     return damage
  329.  
  330.        
  331. def e_fireShell(xy,tankx,tanky,turPos,gun_power,xlocation,barrier_width,randomHeight,ptankx,ptanky):
  332.  
  333.     damage = 0
  334.     currentPower = 1
  335.     power_found = False
  336.  
  337.     while not power_found:
  338.         currentPower += 1
  339.         if currentPower > 100:
  340.             power_found = True
  341.         #print(currentPower)
  342.  
  343.         fire = True
  344.         startingShell = list(xy)
  345.  
  346.  
  347.         while fire:
  348.             for event in pygame.event.get():
  349.                 if event.type == pygame.QUIT:
  350.                     pygame.quit()
  351.                     quit()
  352.  
  353.             #pygame.draw.circle(gameDisplay, red, (startingShell[0],startingShell[1]),5)
  354.  
  355.             startingShell[0] += (12 - turPos)*2
  356.             startingShell[1] += int((((startingShell[0]-xy[0])*0.015/(currentPower/50))**2) - (turPos+turPos/(12-turPos)))
  357.  
  358.             if startingShell[1] > display_height-ground_height:
  359.                 hit_x = int((startingShell[0]*display_height-ground_height)/startingShell[1])
  360.                 hit_y = int(display_height-ground_height)
  361.                 #explosion(hit_x,hit_y)
  362.                 if ptankx+15 > hit_x > ptankx - 15:
  363.                     print("target acquired!")
  364.                     power_found = True
  365.                 fire = False
  366.  
  367.             check_x_1 = startingShell[0] <= xlocation + barrier_width
  368.             check_x_2 = startingShell[0] >= xlocation
  369.  
  370.             check_y_1 = startingShell[1] <= display_height
  371.             check_y_2 = startingShell[1] >= display_height - randomHeight
  372.  
  373.             if check_x_1 and check_x_2 and check_y_1 and check_y_2:
  374.                 hit_x = int((startingShell[0]))
  375.                 hit_y = int(startingShell[1])
  376.                 #explosion(hit_x,hit_y)
  377.                 fire = False
  378.    
  379.  
  380.    
  381.     fire = True
  382.     startingShell = list(xy)
  383.     print("FIRE!",xy)
  384.  
  385.     while fire:
  386.         for event in pygame.event.get():
  387.             if event.type == pygame.QUIT:
  388.                 pygame.quit()
  389.                 quit()
  390.  
  391.         #print(startingShell[0],startingShell[1])
  392.         pygame.draw.circle(gameDisplay, red, (startingShell[0],startingShell[1]),5)
  393.  
  394.  
  395.         startingShell[0] += (12 - turPos)*2
  396.  
  397.  
  398.  
  399.         # y = x**2
  400.         startingShell[1] += int((((startingShell[0]-xy[0])*0.015/(currentPower/50))**2) - (turPos+turPos/(12-turPos)))
  401.  
  402.         if startingShell[1] > display_height-ground_height:
  403.             print("last shell:",startingShell[0],startingShell[1])
  404.             hit_x = int((startingShell[0]*display_height-ground_height)/startingShell[1])
  405.             hit_y = int(display_height-ground_height)
  406.             print("Impact:",hit_x,hit_y)
  407.             if ptankx + 15 > hit_x > ptankx - 15:
  408.                 print("HIT TARGET!")
  409.                 damage = 25
  410.             explosion(hit_x,hit_y)
  411.             fire = False
  412.  
  413.         check_x_1 = startingShell[0] <= xlocation + barrier_width
  414.         check_x_2 = startingShell[0] >= xlocation
  415.  
  416.         check_y_1 = startingShell[1] <= display_height
  417.         check_y_2 = startingShell[1] >= display_height - randomHeight
  418.  
  419.         if check_x_1 and check_x_2 and check_y_1 and check_y_2:
  420.             print("Last shell:",startingShell[0], startingShell[1])
  421.             hit_x = int((startingShell[0]))
  422.             hit_y = int(startingShell[1])
  423.             print("Impact:", hit_x,hit_y)
  424.             explosion(hit_x,hit_y)
  425.             fire = False
  426.  
  427.        
  428.        
  429.  
  430.         pygame.display.update()
  431.         clock.tick(60)
  432.     return damage
  433.  
  434. def power(level):
  435.     text = smallfont.render("Power: "+str(level)+"%",True, black)
  436.     gameDisplay.blit(text, [display_width/2,0])
  437.  
  438.  
  439.  
  440. def game_intro():
  441.  
  442.     intro = True
  443.  
  444.     while intro:
  445.         for event in pygame.event.get():
  446.                 #print(event)
  447.                 if event.type == pygame.QUIT:
  448.                     pygame.quit()
  449.                     quit()
  450.  
  451.                 if event.type == pygame.KEYDOWN:
  452.                     if event.key == pygame.K_c:
  453.                         intro = False
  454.                     elif event.key == pygame.K_q:
  455.                        
  456.                         pygame.quit()
  457.                         quit()
  458.  
  459.         gameDisplay.fill(white)
  460.         message_to_screen("Welcome to Tanks!",green,-100,size="large")
  461.         message_to_screen("The objective is to shoot and destroy",black,-30)
  462.         message_to_screen("the enemy tank before they destroy you.",black,10)
  463.         message_to_screen("The more enemies you destroy, the harder they get.",black,50)
  464.         #message_to_screen("Press C to play, P to pause or Q to quit",black,180)
  465.  
  466.  
  467.         button("play", 150,500,100,50, green, light_green, action="play")
  468.         button("controls", 350,500,100,50, yellow, light_yellow, action="controls")
  469.         button("quit", 550,500,100,50, red, light_red, action ="quit")
  470.  
  471.  
  472.  
  473.         pygame.display.update()
  474.  
  475.         clock.tick(15)
  476.  
  477. def game_over():
  478.  
  479.     game_over = True
  480.  
  481.     while game_over:
  482.         for event in pygame.event.get():
  483.                 #print(event)
  484.                 if event.type == pygame.QUIT:
  485.                     pygame.quit()
  486.                     quit()
  487.  
  488.         gameDisplay.fill(white)
  489.         message_to_screen("Game Over",green,-100,size="large")
  490.         message_to_screen("You died.",black,-30)
  491.  
  492.  
  493.  
  494.         button("play Again", 150,500,150,50, green, light_green, action="play")
  495.         button("controls", 350,500,100,50, yellow, light_yellow, action="controls")
  496.         button("quit", 550,500,100,50, red, light_red, action ="quit")
  497.  
  498.  
  499.         pygame.display.update()
  500.  
  501.         clock.tick(15)
  502.  
  503. def you_win():
  504.  
  505.     win = True
  506.  
  507.     while win:
  508.         for event in pygame.event.get():
  509.                 #print(event)
  510.                 if event.type == pygame.QUIT:
  511.                     pygame.quit()
  512.                     quit()
  513.  
  514.         gameDisplay.fill(white)
  515.         message_to_screen("You won!",green,-100,size="large")
  516.         message_to_screen("Congratulations!",black,-30)
  517.  
  518.  
  519.  
  520.         button("play Again", 150,500,150,50, green, light_green, action="play")
  521.         button("controls", 350,500,100,50, yellow, light_yellow, action="controls")
  522.         button("quit", 550,500,100,50, red, light_red, action ="quit")
  523.  
  524.  
  525.         pygame.display.update()
  526.  
  527.         clock.tick(15)
  528.  
  529.  
  530. def health_bars(player_health, enemy_health):
  531.  
  532.     if player_health > 75:
  533.         player_health_color = green
  534.     elif player_health > 50:
  535.         player_health_color = yellow
  536.     else:
  537.         player_health_color = red
  538.  
  539.     if enemy_health > 75:
  540.         enemy_health_color = green
  541.     elif enemy_health > 50:
  542.         enemy_health_color = yellow
  543.     else:
  544.         enemy_health_color = red
  545.  
  546.     pygame.draw.rect(gameDisplay, player_health_color, (680, 25, player_health, 25))
  547.     pygame.draw.rect(gameDisplay, enemy_health_color, (20, 25, enemy_health, 25))
  548.  
  549.  
  550.  
  551.  
  552. def gameLoop():
  553.     gameExit = False
  554.     gameOver = False
  555.     FPS = 15
  556.  
  557.     player_health = 100
  558.     enemy_health = 100
  559.  
  560.     barrier_width = 50
  561.  
  562.     mainTankX = display_width * 0.9
  563.     mainTankY = display_height * 0.9
  564.     tankMove = 0
  565.     currentTurPos = 0
  566.     changeTur = 0
  567.  
  568.     enemyTankX = display_width * 0.1
  569.     enemyTankY = display_height * 0.9
  570.  
  571.  
  572.    
  573.  
  574.     fire_power = 50
  575.     power_change = 0
  576.  
  577.     xlocation = (display_width/2) + random.randint(-0.2*display_width, 0.2*display_width)
  578.     randomHeight = random.randrange(display_height*0.1,display_height*0.6)
  579.  
  580.    
  581.     while not gameExit:
  582.        
  583.        
  584.         if gameOver == True:
  585.             #gameDisplay.fill(white)
  586.             message_to_screen("Game Over",red,-50,size="large")
  587.             message_to_screen("Press C to play again or Q to exit",black,50)
  588.             pygame.display.update()
  589.             while gameOver == True:
  590.                 for event in pygame.event.get():
  591.                     if event.type == pygame.QUIT:
  592.                         gameExit = True
  593.                         gameOver = False
  594.  
  595.                     if event.type == pygame.KEYDOWN:
  596.                         if event.key == pygame.K_c:
  597.                             gameLoop()
  598.                         elif event.key == pygame.K_q:
  599.                            
  600.                             gameExit = True
  601.                             gameOver = False
  602.          
  603.  
  604.  
  605.         for event in pygame.event.get():
  606.  
  607.             if event.type == pygame.QUIT:
  608.                 gameExit = True
  609.  
  610.             if event.type == pygame.KEYDOWN:
  611.                 if event.key == pygame.K_LEFT:
  612.                     tankMove = -5
  613.                    
  614.                 elif event.key == pygame.K_RIGHT:
  615.                     tankMove = 5
  616.                    
  617.                 elif event.key == pygame.K_UP:
  618.                     changeTur = 1
  619.                    
  620.                 elif event.key == pygame.K_DOWN:
  621.                     changeTur = -1
  622.  
  623.                 elif event.key == pygame.K_p:
  624.                     pause()
  625.  
  626.                 elif event.key == pygame.K_SPACE:
  627.                     damage = fireShell(gun,mainTankX,mainTankY,currentTurPos,fire_power,xlocation,barrier_width,randomHeight,enemyTankX,enemyTankY)
  628.                     enemy_health -= damage
  629.                     damage = e_fireShell(enemy_gun,enemyTankX,enemyTankY,8,50,xlocation,barrier_width,randomHeight,mainTankX,mainTankY)
  630.                     player_health -= damage
  631.                    
  632.                 elif event.key == pygame.K_a:
  633.                     power_change = -1
  634.                 elif event.key == pygame.K_d:
  635.                     power_change = 1
  636.  
  637.             elif event.type == pygame.KEYUP:
  638.                 if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
  639.                     tankMove = 0
  640.  
  641.                 if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
  642.                     changeTur = 0
  643.                    
  644.                 if event.key == pygame.K_a or event.key == pygame.K_d:
  645.                     power_change = 0
  646.                
  647.  
  648.  
  649.                    
  650.        
  651.         mainTankX += tankMove
  652.  
  653.         currentTurPos += changeTur
  654.  
  655.         if currentTurPos > 8:
  656.             currentTurPos = 8
  657.         elif currentTurPos < 0:
  658.             currentTurPos = 0
  659.  
  660.  
  661.         if mainTankX - (tankWidth/2) < xlocation+barrier_width:
  662.             mainTankX += 5
  663.            
  664.  
  665.         gameDisplay.fill(white)
  666.         health_bars(player_health,enemy_health)
  667.         gun = tank(mainTankX,mainTankY,currentTurPos)
  668.         enemy_gun = enemy_tank(enemyTankX, enemyTankY, 8)
  669.         fire_power += power_change
  670.  
  671.         power(fire_power)
  672.  
  673.         barrier(xlocation,randomHeight,barrier_width)
  674.         gameDisplay.fill(green, rect=[0, display_height-ground_height, display_width, ground_height])
  675.         pygame.display.update()
  676.  
  677.         if player_health < 1:
  678.             game_over()
  679.         elif enemy_health < 1:
  680.             you_win()
  681.         clock.tick(FPS)
  682.  
  683.     pygame.quit()
  684.     quit()
  685.  
  686. game_intro()
  687. gameLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement