Unbewohnte
4 years ago
4 changed files with 56 additions and 46 deletions
@ -1,25 +1,33 @@ |
|||||||
import pygame |
import pygame |
||||||
from random import randint |
from random import randint,randrange |
||||||
|
|
||||||
particles_on_screen = [] |
|
||||||
|
|
||||||
|
particles_on_screen_e = [] |
||||||
|
particles_on_screen_p = [] |
||||||
class Particle: |
class Particle: |
||||||
def __init__(self,x,y): |
def __init__(self,x,y): |
||||||
self.x = x |
self.x = x |
||||||
self.y = y |
self.y = y |
||||||
self.width = 4 |
self.width = 4 #4 |
||||||
self.height = self.width |
self.height = self.width |
||||||
self.vel = int(randint(0,3)/5) |
self.vel = int(randint(0,3)/5) |
||||||
self.rect = pygame.Rect(self.x,self.y,self.width,self.height) |
self.rect = pygame.Rect(self.x,self.y,self.width,self.height) |
||||||
self.timer = randint(10,40) |
self.timer = randint(10,66) |
||||||
def draw(self,window): |
def draw(self,window): |
||||||
for i in range(5): #+ randint(-30,30) |
for i in range(5): #5 |
||||||
pygame.draw.rect(window,(randint(200,255),randint(170,255),20),(self.rect[0] + randint(-35,35), self.rect[1] + randint(-30,30), self.rect[2], self.rect[3])) |
pygame.draw.rect(window,(randint(200,255),randint(50,255),20),(self.rect[0] + randint(-35,35), self.rect[1] + randint(-30,30), self.rect[2], self.rect[3])) |
||||||
def update(self): |
def update(self,side): |
||||||
for particle in particles_on_screen: |
if str(side) == "up": |
||||||
self.timer -= 0.5 |
for particle in particles_on_screen_e: |
||||||
#self.x += self.vel - randint(1,2) |
particle.timer -= 0.5 |
||||||
self.rect[1] += self.vel + int(randint(-6,1)) #self.vel + |
#self.rect[1] -= (self.vel - randrange(-7,1)) |
||||||
self.rect[0] += self.vel + int(randint(-1,1)) |
particle.rect[1] += (self.vel + randrange(-7,1)) |
||||||
|
particle.rect[0] += (self.vel + randrange(-3,3)) |
||||||
|
if particle.timer <= 0: |
||||||
|
particles_on_screen_e.remove(particle) |
||||||
|
if str(side) == "down": |
||||||
|
for particle in particles_on_screen_p: |
||||||
|
particle.timer -= 0.5 |
||||||
|
particle.rect[1] += (self.vel + randrange(-1,7)) |
||||||
|
particle.rect[0] += (self.vel + randrange(-3,3)) |
||||||
if particle.timer <= 0: |
if particle.timer <= 0: |
||||||
particles_on_screen.remove(particle) |
particles_on_screen_p.remove(particle) |
||||||
|
Loading…
Reference in new issue