Advertisement
Guest User

Untitled

a guest
Apr 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. import pygame_sdl2
  2. from time import sleep
  3. pygame_sdl2.import_as_pygame()
  4.  
  5. def main():
  6. pygame_sdl2.init()
  7.  
  8. #Variaveis do sistema.
  9. close = False
  10.  
  11. display = pygame_sdl2.display.set_mode((600,600))
  12. pygame_sdl2.display.set_caption('Jogo do exorcista')
  13.  
  14. pygame_sdl2.font.init()
  15. font_default = pygame_sdl2.font.get_default_font()
  16. text_win = pygame_sdl2.font.Font(font_default, 100)
  17. text_lose = pygame_sdl2.font.Font(font_default, 50)
  18.  
  19. cor_vermelha = (255,0,0)
  20. cor_verde = (0,255,0)
  21. cor_azul = (0,0,255)
  22. cor_preta = (0,0,0)
  23.  
  24. player = pygame_sdl2.Rect(0,50,60,50)
  25. piso1 = pygame_sdl2.Rect(0,100,630,60)
  26. piso2 = pygame_sdl2.Rect(70,230,680,60)
  27. piso3 = pygame_sdl2.Rect(0,390,630,60)
  28. piso4 = pygame_sdl2.Rect(80,540,680,60)
  29. piso5 = pygame_sdl2.Rect(0,680,630,60)
  30. piso6 = pygame_sdl2.Rect(80,820,680,60)
  31. piso7 = pygame_sdl2.Rect(0,960,630,60)
  32. piso8 = pygame_sdl2.Rect(80,1100,680,60)
  33. piso9 = pygame_sdl2.Rect(0,1240,630,60)
  34. piso10 = pygame_sdl2.Rect(630,1240,100,40)
  35.  
  36. pisos = [piso1,piso2,piso3,piso4,piso5,piso6,piso7,piso8,piso9]
  37.  
  38. audio_grito = pygame_sdl2.mixer.Sound('grito.ogg')
  39. audio_vitoria = pygame_sdl2.mixer.Sound('vitoria.ogg')
  40.  
  41. clock = pygame_sdl2.time.Clock()
  42.  
  43. while close != True:
  44.  
  45. for event in pygame_sdl2.event.get():
  46. if event.type == pygame_sdl2.QUIT:
  47. close = True
  48.  
  49. (xant,yant) = (player.left,player.top)
  50. if event.type == pygame_sdl2.KEYDOWN:
  51.  
  52. if event.key == pygame_sdl2.K_b:
  53. player.move_ip(20,0)
  54. if event.key == pygame_sdl2.K_c:
  55. player.move_ip(-20,0)
  56. if event.key == pygame_sdl2.K_g:
  57. player.move_ip(0,-20)
  58. if event.key == pygame_sdl2.K_v:
  59. player.move_ip(0,20)
  60.  
  61. clock.tick(30)
  62.  
  63. display.fill(cor_azul)
  64.  
  65. pygame_sdl2.draw.rect(display,cor_vermelha,player)
  66. pygame_sdl2.draw.rect(display,cor_preta,piso1)
  67. pygame_sdl2.draw.rect(display,cor_preta,piso2)
  68. pygame_sdl2.draw.rect(display,cor_preta,piso3)
  69. pygame_sdl2.draw.rect(display,cor_preta,piso4)
  70. pygame_sdl2.draw.rect(display,cor_preta,piso5)
  71. pygame_sdl2.draw.rect(display,cor_preta,piso6)
  72. pygame_sdl2.draw.rect(display,cor_preta,piso7)
  73. pygame_sdl2.draw.rect(display,cor_preta,piso8)
  74. pygame_sdl2.draw.rect(display,cor_preta,piso9)
  75. pygame_sdl2.draw.rect(display,cor_verde,piso10)
  76.  
  77. xymouse = pygame_sdl2.mouse.get_pos()
  78. #(player.left,player.top) = xymouse
  79.  
  80. for piso in pisos:
  81. if player.colliderect(piso):
  82. show_lose = text_lose.render('Você perdeu',True,cor_vermelha)
  83. display.blit(show_lose,(230,100))
  84. (player.left,player.top) = (xant,yant)
  85. audio_grito.play()
  86.  
  87. pygame_sdl2.display.update()
  88.  
  89. sleep(7)
  90. pygame_sdl2.quit()
  91.  
  92. if player.colliderect(piso10):
  93. show_win = text_win.render('Você ganhou!',True,cor_verde)
  94. display.blit(show_win,(30,100))
  95. (player.left,player.top) = (xant,yant)
  96. audio_vitoria.play()
  97.  
  98. pygame_sdl2.display.update()
  99.  
  100. sleep(8)
  101. pygame_sdl2.quit()
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. pygame_sdl2.display.update()
  112.  
  113. pygame_sdl2.quit()
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement