def __init__(self, image_surface, pivot=None, uuid=0): super(RenderableObject, self).__init__(uuid) img_width = image_surface.get_width() img_height = image_surface.get_height() # Set up pivot for the image pivot = Vector2(img_width / 2, img_height / 2) if pivot is None else Vector2(0, 0) self.transform = Transform(Vector2(0, 0)) self.renderer = Renderer(image_surface, pivot) self.add_component(self.transform) self.add_component(self.renderer)
def __init__(self, image_surface, uuid=0): super(GameObject, self).__init__(uuid) img_width = image_surface.get_width() img_height = image_surface.get_height() # Set up pivot for the image pivot = Vector2(img_width / 2, img_height / 2) self.transform = Transform(Vector2(0, 0)) self.renderer = Renderer(image_surface, pivot) self.collider = components.BoxCollider(img_width, img_height) self.add_component(self.transform) self.add_component(self.renderer) self.add_component(self.collider)
def __init__(self, width, height, uuid=0): super(BoxColliderObject, self).__init__(uuid) self.transform = Transform(Vector2(0, 0)) self.collider = components.BoxCollider(width, height) self.add_component(self.transform) self.add_component(self.collider)
def set_box_attributes(box): box.renderer.depth = 2 box.collider.restitution = 0 box.collider.surface_friction = 0.8 box.collider.box.w -= 10 box.collider.box.h -= 10 box.add_component(RigidBody()) box.rigid_body.velocity = Vector2(0.0, 0.0) box.rigid_body.gravity_scale = 2.0 box.tag = "box"
def __init__(self, image_surface=None, pos=Vector2(0, 0)): self.uuid = 0 self.position = pos self.image = image_surface self.tag = ""