def next_frame(self): self.planets = [ Planet(hexmodel=self.hexes, pos=choice(helpfunc.hex_ring(helpfunc.get_center(h), 5)), center=(h, randint(-1, 1), randint(-1, 1)), color=random_hue(), direction=helpfunc.plus_or_minus()) for h in helpfunc.all_hexes() ] while True: if len(self.planets) < (NUM_HEXES * 2) and helpfunc.one_in(20): h = helpfunc.get_random_hex() self.planets.append( Planet(hexmodel=self.hexes, pos=choice( helpfunc.hex_ring(helpfunc.get_center(h), 5)), center=(h, randint(-1, 1), randint(-1, 1)), color=random_hue(), direction=helpfunc.plus_or_minus())) self.hexes.black_all_cells() # Draw the Planets for planet in self.planets: planet.draw_planet() if not planet.move_planet(): for direction in helpfunc.all_dir( ): # Cause explosion of bullets bullet_color = (255 + planet.color + randint(-15, 15)) % 255 self.bullets.append( Bullet(hexmodel=self.hexes, color=bullet_color, pos=planet.pos, direction=direction)) self.planets.remove(planet) # Kill Planet # Draw the Bullets for bullet in self.bullets: bullet.draw_bullet() if not bullet.move_bullet(): self.bullets.remove(bullet) self.color = (self.color + 1) % 255 # Change the colors yield self.speed
def next_frame(self): while True: if len(self.sprockets) < helpfunc.NUM_HEXES: for h in helpfunc.all_hexes(): self.sprockets.append( Sprocket(self.hexes, center=helpfunc.get_center(h), color=random_hue(), min=randint(1, 4), thick=7)) self.hexes.black_all_cells() # Draw the Sprockets for sprocket in self.sprockets: sprocket.draw_sprocket(self.clock) if not sprocket.move_sprocket: self.sprockets.remove(sprocket) # Draw the Bullets for bullet in self.bullets: bullet.draw_bullet() if not bullet.move_bullet(): self.bullets.remove(bullet) yield self.speed # random time set in init function self.clock += self.direction if helpfunc.one_in(50): self.direction *= -1
def __init__(self, hexmodel): self.name = "Planets" self.hexes = hexmodel self.planets = [] # List that holds Planet objects self.bullets = [] # List that holds Bullet objects self.speed = 1.0 / randint(2, 10) self.color = random_hue()
def move_eye_ball(self): if self.ball_move == 10: if one_in(30): self.ball_move = rand_dir() else: self.ball_pos = hex_in_direction(self.ball_pos, self.ball_move) if self.ball_pos in hex_ring((self.h, 0, 0), 3): self.ball_move = (self.ball_move + 3) % 6 if self.ball_pos == (self.h, 0, 0): self.ball_move = 10 if self.ray == -1: self.ray_pos = self.ball_pos self.ray = 0 # Start the eye-ray self.ray_color = random_hue() if one_in(20): self.big_ball = not self.big_ball # Change pupil size
def __init__(self, hexmodel): self.name = "Circling" self.hexes = hexmodel self.planets = [] # List that holds Planet objects self.speed = 0.05 self.color = random_hue()