Exemple #1
0
 def __init__(self, hexmodel, maincolor):
     self.hexes = hexmodel
     self.color = random_color_range(maincolor, 30)
     self.pos = self.hexes.rand_cell()
     self.size = randint(2, 5)
     self.dir = rand_dir()
     self.life = randint(50, 200)  # how long a ball is around
Exemple #2
0
 def __init__(self, hexmodel):
     self.name = "Branches"
     self.hexes = hexmodel
     self.live_branches = []  # List that holds Branch objects
     self.main_color = random_color()
     self.main_dir = rand_dir()
     self.speed = 0.1
Exemple #3
0
 def move_ball(self):
     while True:
         new_spot = hex_in_direction(self.pos, self.dir)  # Where is the ball going?
         if self.hexes.cell_exists(new_spot):  # Is new spot off the board?
             self.pos = new_spot  # On board. Update spot
             break
         self.dir = rand_dir()  # Off board. Pick a new direction
Exemple #4
0
 def __init__(self, hexmodel):
     self.name = "Center Branches"
     self.hexes = hexmodel
     self.live_branches = []  # List that holds Branch objects
     self.main_color = random_color()
     self.main_dir = rand_dir()
     self.inversion = randint(0, 1)  # Toggle for effects
     self.speed = 0.05
Exemple #5
0
 def __init__(self, hexmodel, h):
     self.hexes = hexmodel
     self.h = h
     self.pos = (h, randint(-2, 2), randint(-2, 2))
     self.color = random_color()
     self.direction = rand_dir()
     self.turny = 3
     self.speedy = 15
     self.shooty = 3
Exemple #6
0
    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
Exemple #7
0
    def next_frame(self):

        while True:

            for h in range(NUM_HEXES):
                self.live_branches.append(
                    Branch(hexmodel=self.hexes,
                           position=(get_center(h)),
                           color=self.main_color,
                           direction=rand_dir(),
                           life=0))

            for branch in self.live_branches:
                branch.draw_branch(self.inversion)

                # Chance for branching
                if one_in(20):  # Create a fork
                    self.live_branches.append(
                        Branch(hexmodel=self.hexes,
                               position=branch.pos,
                               color=branch.color,
                               direction=turn_left_or_right(branch.direction),
                               life=branch.life))

                if not branch.move_branch():  # branch has moved off the board
                    self.live_branches.remove(branch)  # kill the branch

            # Randomly change the main color
            if one_in(10):
                self.main_color = random_color_range(self.main_color, 0.2)

            yield self.speed  # random time set in init function


# class CenterBranches(object):
# 	def __init__(self, hexmodel):
# 		self.name = "Center Branches"
# 		self.hexes = hexmodel
# 		self.livebranches = []	# List that holds Branch objects
# 		self.speed = 0.05
# 		self.maincolor =  randint(0,255)	# Main color of the show
# 		self.inversion = randint(0,1)	# Toggle for effects
#
# 	def next_frame(self):
#
# 		while (True):
#
# 			# Add a center branch
#
# 			newbranch = Branch(self.hexes,
# 					self.maincolor, 	# color
# 					(0,0), 				# center
# 					randint(0,5), 		# Random initial direction
# 					0)					# Life = 0 (new branch)
# 			self.livebranches.append(newbranch)
#
# 			for b in self.livebranches:
# 				b.draw_branch(self.inversion)
#
# 				# Chance for branching
# 				if randint(0,20) == 1:	# Create a fork
# 					if randint(0,1) == 1:
# 						newdir = (5 + b.dir - 1) % 5 # fork left
# 					else:
# 						newdir = (b.dir + 1) % 5 # fork right
# 					newbranch = Branch(self.hexes, b.color, b.pos, newdir, b.life)
# 					self.livebranches.append(newbranch)
#
# 				if b.move_branch() == False:	# branch has moved off the board
# 					self.livebranches.remove(b)	# kill the branch
#
# 			self.hexes.go()
#
# 			# Randomly change the main color
# 			if randint(0,10) == 1:
# 				self.maincolor = (255 + randint(-10,10) + self.maincolor) % 255
#
#
# 			yield self.speed  	# random time set in init function