Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. import pygame
  2. import random
  3. w = int(input())
  4. h = int(input())
  5. size = 40
  6. #listX = []
  7. #listY = []
  8.  
  9. def fielding(h, w, size):
  10. for i in range(h):
  11. for j in range(w):
  12. pygame.draw.rect(sc, (255, 255, 255), (20 + jsize, 20 + isize, size, size), 2)
  13.  
  14. def draw_obj(x, y, c):
  15. global size
  16. #def rerandomX():
  17. # for i in listX:
  18. # if x == listX[i]:
  19. # x = random.randrange(1, h, 1)
  20. # rerandomX()
  21. #def rerandomY():
  22. # for i in listY:
  23. # if y == listY[i]:
  24. # y = random.randrange(1, h, 1)
  25. # rerandomY()
  26. if c != e:
  27.  
  28. pygame.draw.circle(sc, (0, 255, 0), (20 + x * size - size // 2, 20 + y * size - size // 2), size // 2)
  29. c = c + 1
  30.  
  31. x = random.randrange(1, h, 1)
  32. y = random.randrange(1, w, 1)
  33.  
  34. if e != c:
  35. # listX = listX + x
  36. # listY = listY + y
  37. draw_obj(x,y,c)
  38.  
  39. pygame.init()
  40.  
  41. sc = pygame.display.set_mode((20 + wsize + 20 + 200, 20 + hsize + 20))
  42.  
  43. fielding(h, w, size)
  44. e = 0.4 * h * w
  45. c = 0
  46. x = random.randrange(1, h, 1)
  47. y = random.randrange(1, w, 1)
  48. draw_obj(x, y, c)
  49.  
  50. pygame.display.update()
  51.  
  52. while 1:
  53. pygame.time.delay(1000)
  54. for i in pygame.event.get():
  55. if i.type == pygame.QUIT:
  56. exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement