示例#1
0
文件: wall.py 项目: cloew/NytramPong
 def build(cls, scene, position):
     """ Build the Entity """
     entity = Entity(scene, renderer=cls.renderer)
     fixture = Fixture(Box(30, 2), density=1, restitution=0, friction=0, isSensor=False)
     entity.body = Body([fixture], bodyType=BodyTypes.Static, fixedRotation=True)
     entity.transform.position = position
     entity.collider = Collider([fixture], {CollisionRegistration(Collidables.Ball, Collidables.Wall, actsAs=Collidables.Wall)})
     return entity
示例#2
0
 def build(cls, scene, position, team):
     """ Build the Entity """
     entity = Entity(scene)
     fixture = Fixture(Box(2, 20), density=1, restitution=0, friction=0, isSensor=True)
     entity.body = Body([fixture], bodyType=BodyTypes.Static, fixedRotation=True)
     entity.transform.position = position
     entity.collider = Collider([fixture], {CollisionRegistration(Collidables.Ball, Collidables.Goal, actsAs=Collidables.Goal)})
     entity.goal = Goal(team)
     return entity
示例#3
0
 def build(cls, scene, position, upKey, downKey):
     """ Build the Entity """
     entity = Entity(scene, renderer=cls.renderer)
     dynamicFixture = Fixture(Box(1, 5), density=1, restitution=0, friction=0, isSensor=False, filter=Filter(categoryBits=CollidableCategories.DynamicPaddle, maskBits=~CollidableCategories.Ball))
     kinematicFixture = Fixture(Box(1, 5), density=1, restitution=0, friction=0, isSensor=False, filter=Filter(categoryBits=CollidableCategories.KinematicPaddle, maskBits=CollidableCategories.Ball))
     entity.body = PlayerBody([dynamicFixture], [kinematicFixture], fixedRotation=True)
     entity.transform.position = position
     entity.collider = Collider([kinematicFixture], {CollisionRegistration(Collidables.Ball, Collidables.Wall, actsAs=Collidables.Wall)})
     entity.movement = Movement({"Up":[0,1], "Down":[0,-1]}, InstantVelocity(5, axis=Axis.Vertical))
     entity.player = Player(upKey, downKey)
     return entity
示例#4
0
 def build(cls, scene, position):
     """ Build the Entity """
     entity = Entity(scene, renderer=cls.renderer)
     fixture = Fixture(Box(1, 1), density=1, restitution=1, friction=0, isSensor=False, filter=Filter(categoryBits=CollidableCategories.Ball))
     entity.body = Body([fixture], bodyType=BodyTypes.Dynamic, fixedRotation=True)
     entity.transform.position = position
     entity.collider = Collider([fixture], {CollisionRegistration(Collidables.Ball, Collidables.Wall, actsAs=Collidables.Ball),
                                            CollisionRegistration(Collidables.Ball, Collidables.Goal, actsAs=Collidables.Ball)})
     entity.movement = BallMovement(5)
     entity.ball = Ball()
     return entity