本文整理汇总了Python中HelperFunctions.random_rgb方法的典型用法代码示例。如果您正苦于以下问题:Python HelperFunctions.random_rgb方法的具体用法?Python HelperFunctions.random_rgb怎么用?Python HelperFunctions.random_rgb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HelperFunctions
的用法示例。
在下文中一共展示了HelperFunctions.random_rgb方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import random_rgb [as 别名]
def __init__(self, colour=None, size=None, position=None):
pygame.sprite.Sprite.__init__(self)
# Make sure snake valid parameters
if colour == None:
colour = Snake._DEFAULT_COLOUR
if size == None:
size = Snake._DEFAULT_SIZE
#if size[0] != size[1]:
# raise Exception('Invalid tile size. Width and height must be equal.')
if position == None:
position = Snake._DEFAULT_POSITION
self.color = colour
self.size = size
#self.head = Snake._SnakeHead(colour, size, position)
self.segments.append(Snake._SnakeSegment(colour, size, position))
self.head = self.segments[0]
#self.tail = Snake._SnakeTail()
self.curseTail = 0
self.direction = Snake.SnakeMove.UP
print "TODO: make this use self.adjust_tail_size()"
for x in range(1, Config.INITIAL_LENGTH): # Initial Length
tailposition = [(position[0] - x*size[0]), position[1]]
# self.tail.add_tail_section(colour, size, tailposition)
self.segments.append(Snake._SnakeSegment(HelperFunctions.random_rgb(), size, tailposition))
示例2: adjust_tail_size
# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import random_rgb [as 别名]
def adjust_tail_size(self, number):
size = self.size[0]
current_direction = self.direction
if number > 0:
for count in range(number):
# ### TODO - randomly generate from the colour of the food eaten
if self.curseTail > 0:
colour = Config.BACKGROUND_COLOUR
else:
colour = HelperFunctions.random_rgb()
# Randomise colour of new tail section
lastindex = len(self.segments) - 1
X = self.segments[lastindex].rect.topleft[0]
Y = self.segments[lastindex].rect.topleft[1]
# New tail section position
if current_direction == Snake.SnakeMove.RIGHT:
X = X - size + (count*size)
elif current_direction == Snake.SnakeMove.LEFT:
X = X + size + (count*size)
elif current_direction == Snake.SnakeMove.UP:
Y = Y - size + (count*size)
elif current_direction == Snake.SnakeMove.DOWN:
Y = Y + size + (count*size)
self.segments.append(Snake._SnakeSegment(colour, self.size, [X, Y]))
else:
for count in range(abs(number)):
# leave at least the head
if(len(self.segments) > 1):
del self.segments[-1]
示例3: curse_tail
# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import random_rgb [as 别名]
def curse_tail(self):
self.randomize_snake_colour()
self.curseTail = Config.FOOD_CURSE_TIME_TO_WEAR_OFF * Config.FPS
for (idx, s) in enumerate(self.segments):
if idx > 0:
s.set_colour(Config.BACKGROUND_COLOUR)
else:
s.set_colour(HelperFunctions.random_rgb())
示例4: randomize_snake_colour
# 需要导入模块: import HelperFunctions [as 别名]
# 或者: from HelperFunctions import random_rgb [as 别名]
def randomize_snake_colour(self):
for s in self.segments:
s.set_colour(HelperFunctions.random_rgb())