def __init__(self, timer): super().__init__(timer) self.timerX = Timer(timer.duration * 1.1, repeat=timer.repeat) self.plasma = plasma.Plasma() self.life = life.Life() self.life.addGlider((4, 4), 0, Direction.northeast) self.timer.fun = lambda: self.life.step()
def start(self,count,**params): info("start life") self.fluepdot.rendering.setMode(Fluepdot.Mode.diff) mask = self.fluepdot.buffer.read() self.life = life.Life(mask=mask) self.draw(**params) return True
def start(self, count, randomize, step, **params): info("start life") self.fluepdot.rendering.setMode(Fluepdot.Mode.diff) mask = self.fluepdot.buffer.read() self.life = life.Life(mask=mask) if randomize: for c in range(count): a, b = int(2. * (random.getrandbits(1) - 0.5)), (int( 2. * (random.getrandbits(1) - 0.5))) log("got random {:d},{:d}".format(a, b)) direction = Direction((a, b)) log("got direction {:s}".format(str(direction))) pos = Position(random.randint(0, FRAMESIZE.w - 1), random.randint(0, FRAMESIZE.h - 1)) step = random.randint(0, 3) log("add glider #{:d} at {:d}/{:d} course {:s}".format( c, pos.x, pos.y, str(direction))) self.life.spawn(life.Pattern.glider, pos=pos, step=step) else: d = int(FRAMESIZE.w / count) direction = Direction.southeast stp = step % 4 pos = Position(int(FRAMESIZE.w / 2), int(FRAMESIZE.h / 2)) for c in range(count): log("add glider #{:d} at {:d}/{:d} course {:s}".format( c, pos.x, pos.y, str(direction))) self.life.spawn(life.Pattern.glider, pos=pos, step=stp) pos = Position((pos.x + d) % FRAMESIZE.w, pos.y) lon, lat = direction.value direction = Direction((lon * -1, lat * -1)) stp = (stp + 1) % 5 # self.life.addGlider(direction=Direction.SouthEast) # self.life.addGlider(pos=(25,4),step=2,direction=Direction.NorthEast) # self.life.addGlider(pos=(50,6),step=4,direction=Direction.SouthWest) # self.life.addGlider(pos=(100,8),step=3,direction=Direction.NorthWest) self.mask = self.draw(**params) return True
def start(self,x,y,randomize,pattern,step,count,flip,**params): info("start spawn {:s}".format(pattern.name.lower())) self.fluepdot.rendering.setMode(Fluepdot.Mode.diff) self.life = life.Life(mask=self.mask) if randomize: for c in range(count): pos = Position(random.randint(0,FRAMESIZE.w-1),random.randint(0,FRAMESIZE.h-1)) self.life.spawn(pattern,pos,step,random.choice( list(Flip) )) else: pos = Position(x,y) self.life.spawn(pattern,pos,step,flip) self.draw(**params) return True
def start(self, randomize, **params): info("start guns") self.fluepdot.rendering.setMode(Fluepdot.Mode.diff) self.life = life.Life(mask=self.mask) pos1 = Position(10, 2) pos2 = Position(60, 7) off1 = Position(x=24, y=10) off2 = Position(x=24, y=-5) self.life.spawn(life.Pattern.gun, pos=pos1) self.life.spawn(life.Pattern.eater, pos=pos1 + off1) self.life.spawn(life.Pattern.gun, pos=pos2, flip=Flip.horizontal) self.life.spawn(life.Pattern.eater, pos=pos2 + off2, flip=Flip.horizontal) self.mask = Mask(self.life) self.draw(**params) return True