import ode, pygame, os from pygame.locals import * from functions import load_image, normalize from random import randint class Particle(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) a = randint(1,3) self.image, self.rect = load_image("blood0"+str(a)+".png",-1) self.image.set_alpha(randint(150,250)) class Blood: def __init__(self,opcje): self.particles = [] for i in range(opcje["BloodAmount"]): self.particles.append(Particle()) #self.particles[-1].image, self.particles[-1].rect = load_image('blood.png', -1) def spawn(self,startpos,direction): x,y = startpos[0],startpos[1] dirx,diry = direction[0],direction[1] for drop in self.particles: drop.rect.center = (x+randint(-10,10), y+randint(-10,10)) drop.dir = (dirx+randint(-20,20), diry+randint(-20,20)) drop.speed = randint(5,10) drop.life = randint(5,15) def update(self,tlo): for drop in self.particles: drop.dir = normalize(drop.dir) drop.rect.center = (drop.rect.center[0]+drop.dir[0]*drop.speed,drop.rect.center[1]+drop.dir[1]*drop.speed) drop.life -= 1 if (drop.life == 0): tlo.blit(drop.image,drop.rect.center) #self.particles.remove(drop)