当前位置: 首页>>代码示例>>Python>>正文


Python HelperFunctions.random_rgb方法代码示例

本文整理汇总了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))
开发者ID:jamietanna,项目名称:PySnake,代码行数:33,代码来源:Snake_Module.py

示例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]
开发者ID:jamietanna,项目名称:PySnake,代码行数:36,代码来源:Snake_Module.py

示例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())
开发者ID:jamietanna,项目名称:PySnake,代码行数:13,代码来源:Snake_Module.py

示例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())
开发者ID:jamietanna,项目名称:PySnake,代码行数:5,代码来源:Snake_Module.py


注:本文中的HelperFunctions.random_rgb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。