Ejemplo n.º 1
0
    def __init__(self, scale_pos_x, scale_pos_y):
        super(Flappy, self).__init__()
        self.display_width = Assets.get().display_width
        self.display_height = Assets.get().display_height

        self.default_position = (int(scale_pos_x * self.display_width),
                                 int(scale_pos_y * self.display_height))
        debugger("Flappy: __init__: default_position = {}".format(self.default_position))

        # scaling physics with display resolution
        self.ACCELERATION *= self.display_height
        self.MAX_VELOCITY *= self.display_height
        self.JUMP_VELOCITY *= self.display_height
        self.IDLE_ANIMATION_MAX_Y *= self.display_height
        self.IDLE_ANIMATION_SPEED *= self.display_height

        # loading flappy assets
        self.FLAPPY_UP_IMAGE = Assets.get().FLAPPY_UP_IMAGE
        self.FLAPPY_IMAGES = Assets.get().FLAPPY_IMAGES

        # the actual image that gets rendered and collision detection mask
        self.image = self.FLAPPY_IMAGES[0]
        self.rect = self.image.get_rect()
        self.hitmask = get_alpha_hitmask(self.image, self.rect)

        # setting Flappy's default values
        self.position = self.default_position
        self.velocity = 0
        self.idle_direction = -1
        self.animation_ms = 0

        self.flappy_flap_listeners = list()
Ejemplo n.º 2
0
    def __init__(self, scale_pos_x, scale_pos_y):
        super(Flappy, self).__init__()
        self.display_width = Assets.get().display_width
        self.display_height = Assets.get().display_height

        self.default_position = (int(scale_pos_x * self.display_width),
                                 int(scale_pos_y * self.display_height))
        debugger("Flappy: __init__: default_position = {}".format(
            self.default_position))

        # scaling physics with display resolution
        self.ACCELERATION *= self.display_height
        self.MAX_VELOCITY *= self.display_height
        self.JUMP_VELOCITY *= self.display_height
        self.IDLE_ANIMATION_MAX_Y *= self.display_height
        self.IDLE_ANIMATION_SPEED *= self.display_height

        # loading flappy assets
        self.FLAPPY_UP_IMAGE = Assets.get().FLAPPY_UP_IMAGE
        self.FLAPPY_IMAGES = Assets.get().FLAPPY_IMAGES

        # the actual image that gets rendered and collision detection mask
        self.image = self.FLAPPY_IMAGES[0]
        self.rect = self.image.get_rect()
        self.hitmask = get_alpha_hitmask(self.image, self.rect)

        # setting Flappy's default values
        self.position = self.default_position
        self.velocity = 0
        self.idle_direction = -1
        self.animation_ms = 0

        self.flappy_flap_listeners = list()
Ejemplo n.º 3
0
    def __init__(self, position, is_top=False):
        super(Pipe, self).__init__()
        self.position = position

        # use different images for top and bottom pipes
        if is_top:
            self.image = Assets.get().PIPE_TOP_IMAGE
        else:
            self.image = Assets.get().PIPE_BOTTOM_IMAGE

        # scaling speed with display resolution
        self.MOVING_SPEED *= self.image.get_width()

        self.rect = self.image.get_rect()
        self.hitmask = get_alpha_hitmask(self.image, self.rect)
Ejemplo n.º 4
0
    def __init__(self, position, is_top=False):
        super(Pipe, self).__init__()
        self.position = position

        # use different images for top and bottom pipes
        if is_top:
            self.image = Assets.get().PIPE_TOP_IMAGE
        else:
            self.image = Assets.get().PIPE_BOTTOM_IMAGE

        # scaling speed with display resolution
        self.MOVING_SPEED *= self.image.get_width()

        self.rect = self.image.get_rect()
        self.hitmask = get_alpha_hitmask(self.image, self.rect)