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


Python pygame.color方法代码示例

本文整理汇总了Python中pygame.color方法的典型用法代码示例。如果您正苦于以下问题:Python pygame.color方法的具体用法?Python pygame.color怎么用?Python pygame.color使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pygame的用法示例。


在下文中一共展示了pygame.color方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_walls

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def add_walls(self):
        self.static_lines = []

        # Add floor
        self.static_lines.append(pymunk.Segment(self.space.static_body,
                                                (0, 1),
                                                (self.res[1], 1), .0))

        # Add roof
        self.static_lines.append(pymunk.Segment(self.space.static_body,
                                                (0, self.res[1]),
                                                (self.res[1], self.res[1]), .0))

        # Set properties
        for line in self.static_lines:
            line.elasticity = .99
            line.color = color["white"]
        self.space.add(self.static_lines)
        return True 
开发者ID:simonkamronn,项目名称:kvae,代码行数:21,代码来源:pong.py

示例2: main

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def main():
    """Initialize and run the game."""
    pygame.init()

    # Initialize PyGame
    screen = pygame.display.set_mode(WINDOW_SIZE, 0, 16)
    pygame.display.set_caption('Python Kinect Game')
    screen.fill(pygame.color.THECOLORS["black"])

    with nui.Runtime() as kinect:
        kinect.skeleton_engine.enabled = True
        kinect.skeleton_frame_ready += post_frame

        # Main game loop
        while True:
            event = pygame.event.wait()

            if event.type == pygame.QUIT:
                break
            elif event.type == KINECTEVENT:
                # process e.skeletons here
                pass 
开发者ID:microsoft,项目名称:PTVS-Samples,代码行数:24,代码来源:Program.py

示例3: init_pockets

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def init_pockets(space):
    pockets = []
    for i in [(44.1, 44.1), (755.9, 44.1), (755.9, 755.9), (44.1, 755.9)]:
        inertia = pymunk.moment_for_circle(0.1, 0, POCKET_RADIUS, (0, 0))
        body = pymunk.Body(0.1, inertia)
        body.position = i
        shape = pymunk.Circle(body, POCKET_RADIUS, (0, 0))
        shape.color = POCKET_COLOR
        shape.collision_type = 2
        shape.filter = pymunk.ShapeFilter(categories=0b1000)
        space.add(body, shape)
        pockets.append(shape)
        del body
        del shape
    return pockets

# Initialize striker with force 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:19,代码来源:Utils.py

示例4: init_striker

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def init_striker(space, x, passthrough, action, player):

    inertia = pymunk.moment_for_circle(STRIKER_MASS, 0, STRIKER_RADIUS, (0, 0))
    body = pymunk.Body(STRIKER_MASS, inertia)
    if player == 1:
        body.position = (action[0], 140)
    if player == 2:
        body.position = (action[0], BOARD_SIZE - 140)
    body.apply_force_at_world_point((cos(action[1]) * action[2], sin(
        action[1]) * action[2]), body.position + (STRIKER_RADIUS * 0, STRIKER_RADIUS * 0))

    shape = pymunk.Circle(body, STRIKER_RADIUS, (0, 0))
    shape.elasticity = STRIKER_ELASTICITY
    shape.color = STRIKER_COLOR

    mask = pymunk.ShapeFilter.ALL_MASKS ^ passthrough.filter.categories

    sf = pymunk.ShapeFilter(mask=mask)
    shape.filter = sf
    shape.collision_type = 2

    space.add(body, shape)
    return [body, shape]

# Adds coins to the board at the given coordinates 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:27,代码来源:Utils.py

示例5: init_striker

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def init_striker(space, x, passthrough, action, player):

    inertia = pymunk.moment_for_circle(STRIKER_MASS, 0, STRIKER_RADIUS, (0, 0))
    body = pymunk.Body(STRIKER_MASS, inertia)
    if player == 1:
        body.position = (action[0], 145)
    if player == 2:
        body.position = (action[0], BOARD_SIZE - 136)
    body.apply_force_at_world_point((cos(action[1]) * action[2], sin(
        action[1]) * action[2]), body.position + (STRIKER_RADIUS * 0, STRIKER_RADIUS * 0))

    shape = pymunk.Circle(body, STRIKER_RADIUS, (0, 0))
    shape.elasticity = STRIKER_ELASTICITY
    shape.color = STRIKER_COLOR

    mask = pymunk.ShapeFilter.ALL_MASKS ^ passthrough.filter.categories

    sf = pymunk.ShapeFilter(mask=mask)
    shape.filter = sf
    shape.collision_type = 2

    space.add(body, shape)
    return [body, shape]

# Adds coins to the board at the given coordinates 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:27,代码来源:Utils.py

示例6: init_pockets

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def init_pockets(space):
    pockets = []
    for i in [(44.1, 43.1), (756.5, 43), (756.5, 756.5), (44, 756.5)]:
        inertia = pymunk.moment_for_circle(0.1, 0, POCKET_RADIUS, (0, 0))
        body = pymunk.Body(0.1, inertia)
        body.position = i
        shape = pymunk.Circle(body, POCKET_RADIUS, (0, 0))
        shape.color = POCKET_COLOR
        shape.collision_type = 2
        shape.filter = pymunk.ShapeFilter(categories=0b1000)
        space.add(body, shape)
        pockets.append(shape)
        del body
        del shape
    return pockets

# Initialize striker with force 
开发者ID:samiranrl,项目名称:Carrom_rl,代码行数:19,代码来源:Utils.py

示例7: create_obstacle

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_obstacle(self, x, y, r):
        c_body = pymunk.Body(pymunk.inf, pymunk.inf)
        c_shape = pymunk.Circle(c_body, r)
        c_shape.elasticity = 1.0
        c_body.position = x, y
        c_shape.color = THECOLORS["blue"]
        self.space.add(c_body, c_shape)
        return c_body 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:10,代码来源:carmunk.py

示例8: create_cat

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_cat(self):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.cat_body = pymunk.Body(1, inertia)
        self.cat_body.position = 50, height - 100
        self.cat_shape = pymunk.Circle(self.cat_body, 30)
        self.cat_shape.color = THECOLORS["orange"]
        self.cat_shape.elasticity = 1.0
        self.cat_shape.angle = 0.5
        direction = Vec2d(1, 0).rotated(self.cat_body.angle)
        self.space.add(self.cat_body, self.cat_shape) 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:12,代码来源:carmunk.py

示例9: create_car

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_car(self, x, y, r):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.car_body = pymunk.Body(1, inertia)
        self.car_body.position = x, y
        self.car_shape = pymunk.Circle(self.car_body, 25)
        self.car_shape.color = THECOLORS["green"]
        self.car_shape.elasticity = 1.0
        self.car_body.angle = r
        driving_direction = Vec2d(1, 0).rotated(self.car_body.angle)
        self.car_body.apply_impulse(driving_direction)
        self.space.add(self.car_body, self.car_shape) 
开发者ID:llSourcell,项目名称:Self-Driving-Car-Demo,代码行数:13,代码来源:carmunk.py

示例10: _clear

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def _clear(self):
        self.screen.fill(color["black"]) 
开发者ID:simonkamronn,项目名称:kvae,代码行数:4,代码来源:pong.py

示例11: __init__

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def __init__(self, pong, position):
            self.pong = pong
            self.area = pong.res
            if position == 'left':
                self.rect = pymunk.Segment(pong.space.static_body,
                                           (0, self.area[1] / 2 + 3*scale),
                                           (0, self.area[1] / 2 - 3*scale), 1.0)
            else:
                self.rect = pymunk.Segment(pong.space.static_body,
                                           (self.area[0] - 2, self.area[1] / 2 + 3*scale),
                                           (self.area[0] - 2, self.area[1] / 2 - 3*scale), 1.0)
            self.speed = 2*scale
            self.rect.elasticity = .99
            self.rect.color = color["white"]
            self.rect.collision_type = 1 
开发者ID:simonkamronn,项目名称:kvae,代码行数:17,代码来源:pong.py

示例12: create_ball

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_ball(self, radius=3):
        inertia = pymunk.moment_for_circle(1, 0, radius, (0, 0))
        body = pymunk.Body(1, inertia)
        position = np.array(self.initial_position) + self.initial_std * np.random.normal(size=(2,))
        position = np.clip(position, self.dd + radius + 1, self.res[0] - self.dd - radius - 1)
        body.position = position

        shape = pymunk.Circle(body, radius, (0, 0))
        shape.elasticity = .9
        shape.color = color["white"]
        return shape 
开发者ID:simonkamronn,项目名称:kvae,代码行数:13,代码来源:pong.py

示例13: create_cat

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_cat(self):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.cat_body = pymunk.Body(1, inertia)
        self.cat_body.position = 800, 200
        self.cat_shape = pymunk.Circle(self.cat_body, 30)
        self.cat_shape.color = THECOLORS["orange"]
        self.car_shape.elasticity = 1.0
        self.cat_shape.angle = 0.5
        self.space.add(self.cat_body, self.cat_shape) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:11,代码来源:carmunk.py

示例14: create_car

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def create_car(self, x, y, r):
        inertia = pymunk.moment_for_circle(1, 0, 14, (0, 0))
        self.car_body = pymunk.Body(1, inertia)
        self.car_body.position = x, y
        self.car_shape = pymunk.Circle(self.car_body, 15)
        self.car_shape.color = THECOLORS["green"]
        self.car_shape.elasticity = 1.0
        self.car_body.angle = r
        self.driving_direction = Vec2d(1, 0).rotated(self.car_body.angle)
        self.car_body.apply_impulse(self.driving_direction)
        self.space.add(self.car_body, self.car_shape) 
开发者ID:harvitronix,项目名称:rl-rc-car,代码行数:13,代码来源:carmunk.py

示例15: draw_ball

# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import color [as 别名]
def draw_ball(screen, ball, color=THECOLORS['blue']):
    p = int(ball.body.position.x), 600-int(ball.body.position.y)
    pygame.draw.circle(screen, color, p, int(ball.radius), 2) 
开发者ID:jseidl,项目名称:virtuaplant,代码行数:5,代码来源:world.py


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