Advertisement
Guest User

game

a guest
Nov 29th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. import pygame
  2. from pygame import *
  3. import sys
  4. import random
  5. import time
  6.  
  7. #things to do!
  8. #Add decent graphics
  9. #Add a level system
  10. #Add decent move system
  11.  
  12. #Game window including game loop
  13. #################################
  14. class game:
  15. pygame.display.update()
  16. pygame.time.Clock(60):
  17. gameloop = True
  18. def game():
  19. while(Gameloop == True):
  20. pygame.init()
  21. window = pygame.display.set_mode((800,600))
  22. pygame.display.set_caption("Game")
  23.  
  24. #Font including Quit & Start options
  25. ######################################
  26. class font:
  27. pygame.font.init()
  28. text = pygame.font.Font.render("To quit Press <Q> To start Press <S>", 255.255.255)
  29. pygame.blit(text, (400,300))
  30. pygame.display.update()
  31. for keys in pygame.event.get():
  32. if(keys == pygame.key.Q):
  33. sys.exit()
  34. pygame.quit()
  35. elif(keys == pygame.event.QUIT()):
  36. sys.exit()
  37. pygame.quit()
  38. elif(keys == pygame.key.S):
  39. #Game
  40.  
  41. #Player movement
  42. ######################################
  43. class move:
  44. xx = 10
  45. yy = 0
  46. move1 = True
  47. for move in pygame.event.get()
  48. while(move1 == True):
  49. #checken of de coords juist zijn
  50. if(move == pygame.key.KEYUP):
  51. yy += 10
  52. xx += 0
  53. pygame.blit(player.player1, (yy, xx))
  54. pygame.display.update(player.player1)
  55. elif(move == pygame.key.KEYDOWN):
  56. xx -= 0
  57. yy -= 10
  58. pygame.blit(player.player1, (yy, xx))
  59. pygame.display.update(player.player1)
  60. elif(move == pygame.key.LEFT):
  61. xx -= 10
  62. yy -= 0
  63. pygame.blit(player.player1, (yy, xx))
  64. pygame.display.update(player.player1)
  65. elif(move == pygame.key.RIGHT):
  66. xx += 10
  67. yy += 0
  68. pygame.blit(player.player1, (yy, xx))
  69. pygame.display.update(player.player1)
  70. #Player,
  71. ###############################
  72.  
  73. class player:
  74. width1 = 4
  75. height1 = 5
  76. player1 = pygame.draw.circle(window, 255.255.255, width1, height1)
  77. if(player1 == pygame.draw.circle(window, 255.255.255, width1,height1)):
  78. pygame.display.update(player1)
  79.  
  80. #Score
  81. ######################################
  82. class score:
  83. score = 0 #Hier nog op terug komen i.v.b met players
  84. pygame.font.init()
  85. for keykes in pygame.event.get():
  86. if(keykes == pygame.key.S):
  87. pygame.font.Font.render("Score:" + score, 255.255.255)
  88. elif(keykes == pygame.key.Q):
  89. pygame.display.quit()
  90. sys.exit()
  91.  
  92.  
  93.  
  94. #Life system including death message
  95. ####################################
  96. class life:
  97. life = 3
  98. if(life == 0)
  99. pygame.font.init()
  100. death1 = pygame.font.Font.render("You Lost you fool!", 255.0.0)
  101. pygame.blit(death1, (400,300))
  102. pygame.display.update(death1)
  103. time.sleep(3)
  104. pygame.display.quit()
  105. sys.exit()
  106. move.move1 = False
  107. game.Gameloop = False
  108.  
  109. elif(enemy.circle.contains(player.player1) and width1 > width and height1 > height and life != 0):
  110. move.move1 = False
  111. pygame.blit(death, (400,300))
  112. pygame.display.update(death)
  113.  
  114. for k in pygame.event.get():
  115. if(k == pygame.key.S):
  116. life -= 1
  117. game.game()
  118. elif(k == pygame.key.Q):
  119. pygame.display.quit()
  120. sys.exit()
  121. game.Gameloop = False
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. #Enemy / point system
  129. ###############################
  130. class enemy:
  131. width = 3
  132. height = 5
  133. move = True
  134. circle = pygame.draw.circle(window, 255.0.0, width, height)
  135. if(circle):
  136. while(move == True):
  137. xx = random.randint(1,800)
  138. yy = random.randint(1,600) #eventueel aanpassen
  139. pygame.blit(circle, (xx, yy))
  140. pygame.display.update(circle)
  141. if(circle.contains(player1) and player.width1 < width and player.height1 < height or circle.colide(player1)) and player.width1 < width and player.height1 < height):
  142. circle.copy()
  143. pygame.blit(circle, (700,500))
  144. score.score += 10
  145. player.width1 += 5
  146. player.height += 5
  147. elif(circle.contains(player1) and player.width1 > width and player.height1 > height or circle.colide(player1)) and player.width1 > width and player.height1 > height):
  148. life.life != 1
  149. if(life.life == 0):
  150. move = False
  151. time.sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement