Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pygame
- import random
- width = 1280
- height = 720
- stars = []
- center_x = width//2
- center_y = height//2
- radius = 10
- def setup(screen, etc):
- class Star:
- def __init__(self):
- self.x = random.randint(-width,width)
- self.y = random.randint(-height,height)
- self.z = random.randint(center_y,width)
- self.pz = self.z
- def update(self):
- self.z -= 10
- 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
- self.x = random.randint(-width, width)
- self.y = random.randint(-height, height)
- self.z = random.randint(center_y, width)
- self.pz = self.z
- def show(self):
- sx = self.x / self.z * center_y + center_x
- sy = self.y / self.z * center_y + center_y
- pygame.draw.circle(screen, etc.color_picker(etc.knob4), (sx,sy), int(radius*5*etc.knob1))
- for i in range(0,101):
- stars.append(Star()) # add 100 random stars to our list
- def draw(screen, etc) :
- etc.color_picker_bg(etc.knob5)
- for star in stars:
- star.update()
- star.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement