本文整理汇总了Python中pymunk.Space方法的典型用法代码示例。如果您正苦于以下问题:Python pymunk.Space方法的具体用法?Python pymunk.Space怎么用?Python pymunk.Space使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymunk
的用法示例。
在下文中一共展示了pymunk.Space方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, game):
super().__init__(game)
self.player = None
self.active = True
self.geometry = list()
self.space = Space()
self.space.gravity = (0, 1000)
self.sprites = LayeredUpdates()
self.event_handler = event_handling.EventQueueHandler()
self.background = resources.gfx("background.png", convert=True)
self.load()
pygame.mixer.music.load(resources.music_path("zirkus.ogg"))
pygame.mixer.music.play(-1)
示例2: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
self.space = pymunk.Space()
self.space.gravity = 0, 200
self.add_wall(self.space, (0, 400), (600, 400)) # ground
self.add_wall(self.space, (0, 0), (0, 600)) # Left side
self.add_wall(self.space, (600, 0), (600, 400)) # right side
示例3: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
self.space = pymunk.Space()
self.space.gravity = 0, 200
self.add_wall((0, 400), (600, 400)) # ground
self.add_wall((0, 0), (0, 600)) # Left side
self.add_wall((600, 0), (600, 400)) # right side
示例4: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, graph_elem):
self.space = pymunk.Space()
self.space.gravity = 0, 200
self.add_wall((0, 400), (600, 400)) # ground
self.add_wall((0, 0), (0, 600)) # Left side
self.add_wall((600, 0), (600, 400)) # right side
self.arena_balls = [] # type: [] Ball
self.graph_elem = graph_elem # type: sg.Graph
示例5: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, graph_elem):
self.space = pymunk.Space()
self.space.gravity = 0, 200
self.add_wall((0, 400), (600, 400)) # ground
self.add_wall((0, 0), (0, 600)) # Left side
self.add_wall((600, 0), (600, 400)) # right side
self.arena_balls = [] # type: List[Ball]
self.graph_elem = graph_elem # type: sg.Graph
示例6: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self):
# Global-ish.
self.crashed = False
# Physics stuff.
self.space = pymunk.Space()
self.space.gravity = pymunk.Vec2d(0., 0.)
# Create the car.
self.create_car(100, 100, 0.5)
# Record steps.
self.num_steps = 0
# Create walls.
static = [
pymunk.Segment(
self.space.static_body,
(0, 1), (0, height), 1),
pymunk.Segment(
self.space.static_body,
(1, height), (width, height), 1),
pymunk.Segment(
self.space.static_body,
(width-1, height), (width-1, 1), 1),
pymunk.Segment(
self.space.static_body,
(1, 1), (width, 1), 1)
]
for s in static:
s.friction = 1.
s.group = 1
s.collision_type = 1
s.color = THECOLORS['red']
self.space.add(static)
# Create some obstacles, semi-randomly.
# We'll create three and they'll move around to prevent over-fitting.
self.obstacles = []
self.obstacles.append(self.create_obstacle(200, 350, 100))
self.obstacles.append(self.create_obstacle(700, 200, 125))
self.obstacles.append(self.create_obstacle(600, 600, 35))
# Create a cat.
self.create_cat()
示例7: __init__
# 需要导入模块: import pymunk [as 别名]
# 或者: from pymunk import Space [as 别名]
def __init__(self, noisey=False, map_style='default'):
# Noisey sensors?
self.noisey = noisey
# Physics stuff.
self.space = pymunk.Space()
self.space.gravity = pymunk.Vec2d(0., 0.)
# Create the car.
self.create_car(100, 100, -0.75)
self.driving_direction = 0
# Record steps.
self.num_steps = 0
# Which map?
self.map_style = map_style
# Create outer walls.
static = [
pymunk.Segment(
self.space.static_body,
(0, 1), (0, height), 1),
pymunk.Segment(
self.space.static_body,
(1, height), (width, height), 1),
pymunk.Segment(
self.space.static_body,
(width-1, height), (width-1, 1), 1),
pymunk.Segment(
self.space.static_body,
(1, 1), (width, 1), 1)
]
for s in static:
s.friction = 1.
s.group = 1
s.collision_type = 1
s.color = THECOLORS['red']
self.space.add(static)
if map_style == 'default':
self.create_default_map()
# Create a cat.
self.create_cat()
elif map_style == 'linear':
# Used for testing a trained model mostly.
self.create_linear_map()
# Initialize our sensors.
self.sensor_obj = sensors.Sensors(width, height, screen, pygame, False)