Advertisement
Guest User

eyesy patch

a guest
Aug 10th, 2022
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. import pygame
  2. import random
  3.  
  4. width = 1280
  5. height = 720
  6. stars = []
  7. center_x = width//2
  8. center_y = height//2
  9. radius = 10
  10.  
  11. def setup(screen, etc):
  12. class Star:
  13. def __init__(self):
  14. self.x = random.randint(-width,width)
  15. self.y = random.randint(-height,height)
  16. self.z = random.randint(center_y,width)
  17. self.pz = self.z
  18.  
  19. def update(self):
  20. self.z -= 10
  21. if self.z < 1: # when our z is reduced too much instead of crashing we remake the points to be at random new spots, this also saves us from having to make a new star too
  22. self.x = random.randint(-width, width)
  23. self.y = random.randint(-height, height)
  24. self.z = random.randint(center_y, width)
  25. self.pz = self.z
  26.  
  27. def show(self):
  28. sx = self.x / self.z * center_y + center_x
  29. sy = self.y / self.z * center_y + center_y
  30. pygame.draw.circle(screen, etc.color_picker(etc.knob4), (sx,sy), int(radius*5*etc.knob1))
  31.  
  32. for i in range(0,101):
  33. stars.append(Star()) # add 100 random stars to our list
  34.  
  35.  
  36.  
  37. def draw(screen, etc) :
  38. etc.color_picker_bg(etc.knob5)
  39. for star in stars:
  40. star.update()
  41. star.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement