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


Python Animation.current_image方法代码示例

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


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

示例1: PickUp

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class PickUp(ServerPickUp):
    def __init__(self, start_position, width, height, image_list, velocity=euclid.Vector2(0.0, 10.0),
                 max_displacement=euclid.Vector2(0, 5)):
        ServerPickUp.__init__(self, start_position, width, height, velocity, max_displacement)

        self.rect = self.server_rect.get_pygame_rect()
        self.animation = Animation(image_list, self)
        self.image = self.animation.current_image()
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:10,代码来源:pick_up.py

示例2: Platform

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class Platform(ServerPlatform):

    def __init__(self, start_position, width, height, image_list, velocity=euclid.Vector2(0.0, 0.0)):
        ServerPlatform.__init__(self, start_position, width, height, velocity)
        self.rect = self.server_rect.get_pygame_rect()
        self.animation = Animation(image_list, self)
        self.image = self.animation.current_image()

    def update(self):
        super(Platform, self).update()
        self.rect = self.server_rect.get_pygame_rect()
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:13,代码来源:platform.py

示例3: Chain

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class Chain(ServerChain):

    def __init__(self, center, width, height, image_list, grapple_projectile, velocity=euclid.Vector2(0.0, 0.0),
                 gravity=euclid.Vector2(0.0, 0.0)):

        ServerChain.__init__(self, center, width, height, grapple_projectile, velocity, gravity)

        self.can_break_rocks = False
        self.rect = self.server_rect.get_pygame_rect()
        self.animation = Animation(image_list, self)
        self.image = self.animation.current_image()

    def update(self):
        super(Chain, self).update()
        self.rect = self.server_rect.get_pygame_rect()
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:17,代码来源:projectile.py

示例4: Projectile

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class Projectile(ServerProjectile):
    def __init__(self, center, shot_from, player, velocity=euclid.Vector2(0.0, 0.0), gravity=euclid.Vector2(0.0, 0.0)):

        ServerProjectile.__init__(self, center, shot_from, player, velocity, gravity)

        bullet_position_vector = euclid.Vector2(self.velocity.x / shot_from.bullet_velocity,
                                                self.velocity.y / shot_from.bullet_velocity)
        self.rect = self.server_rect.get_pygame_rect()
        self.animation = Animation([self.shot_from.bullet_image_list[0]], self)  # image for in flight projectile
        self.image = pygame.transform.rotate(self.animation.current_image(),
                                             self.roto_theta_conversion_tool_extreme(bullet_position_vector))

    def update(self):
        super(Projectile, self).update()
        self.rect = self.server_rect.get_pygame_rect()
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:17,代码来源:projectile.py

示例5: AnimatedObject

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class AnimatedObject(WorldObject):

    def __init__(self, start_position, width, height, image_list, run_time):
        WorldObject.__init__(self, start_position, width, height)
        self.rect = self.server_rect.get_pygame_rect()
        self.default_animation = Animation(image_list, self, run_time)
        self.image = self.default_animation.current_image()

#*************************************************************************************************
#*************************************************************************************************
#used to update object rect
    def update(self):
        self.default_animation.animate_movement()
        self.rect.center = euclid.Vector2(self.start_position.x + self.get_width() / 2,
                                          self.start_position.y + self.get_height() / 2)
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:17,代码来源:background_object.py

示例6: SpritePlayer

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class SpritePlayer(LunarPioneer):

    def __init__(self, start_position, height, length, image_list, weapons, world_object_list_dictionary,
                 spawn_animation, velocity=euclid.Vector2(0.0, 0.0), gravity=euclid.Vector2(0.0, 0.0), health=100.0):

        LunarPioneer.__init__(self, start_position, height, length, weapons, world_object_list_dictionary,
                              velocity, gravity, health)

        #images
        self.spawn_animation = Spawnimation(self.start_position, 90, 651, spawn_animation, self)
        self.dashing_animation = Animation(image_list[9:14], self, .1, self.end_dash_animation)
        self.dust_image_list = image_list[15:21]
        self.running_animation = Animation(image_list[0:9], self, .08)
        self.image = self.running_animation.current_image()

        self.rect = self.server_rect.get_pygame_rect()

        #override
        self.grapple_projectile = Grapple(start_position, self.weapons[0], self)
        self.grapple_projectile.is_alive = False  # kill default grapple

        self.add_to_world(self.spawn_animation, "foreground")

#*************************************************************************************************
#*************************************************************************************************
#gets new image of our running man
    def change_animation(self):

        if self.is_running():
            self.running_animation.animate_movement(self.movement_direction())
            self.image = pygame.transform.flip(self.running_animation.current_image(), not self.is_looking_right, 0)

        elif self.is_dashing:
            self.dashing_animation.animate_movement()
            self.image = pygame.transform.flip(self.dashing_animation.current_image(), not self.is_moving_right, 0)

        #elif self.grapple_projectile.is_alive:
            #self.image = pygame.transform.flip(self.running_animation.image_list[0], not self.is_looking_right, 0)

        #elif self.is_falling():
            #self.image = pygame.transform.flip(self.running_animation.image_list[0], not self.is_looking_right, 0)

        else:  # player is standing still
            self.image = pygame.transform.flip(self.running_animation.image_list[0], not self.is_looking_right, 0)

#*************************************************************************************************
#*************************************************************************************************
#hit top of object
    def collision_above(self, thing_hit):
        if self.is_grappled():
            self.velocity = euclid.Vector2(0.0, 0.0)
        else:
            if not self.can_jump and math.fabs(self.velocity.y) >= math.fabs(self.max_speed.y) - 100.0:
                dust_cloud = DustCloud(euclid.Vector2(self.start_position.x + self.hitbox.width / 2.0 - 150 / 2.0,
                                                      self.start_position.y + self.hitbox.height - 41),
                                       150, 41, self.dust_image_list)
                self.add_to_world(dust_cloud, "foreground")
            self.velocity = euclid.Vector2(self.velocity.x, 0.0)
            self.can_jump = True
        #calculates offset to y position
        self.start_position.y = thing_hit.start_position.y - self.hitbox.height - self.top_padding()
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:63,代码来源:sprite_player.py

示例7: Gun

# 需要导入模块: from animation import Animation [as 别名]
# 或者: from animation.Animation import current_image [as 别名]
class Gun(ServerGun):
    def __init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy, image_list=None,
                 gun_x_position=-10.0, gun_y_position=-10.0, width=80.0, height=25.0, look_left_offset=20.0):
        if image_list is None:
            image_list = [pygame.image.load("resources/images/gunNotShooting.png"),
                          pygame.image.load("resources/images/gunShooting.png")]

        ServerGun.__init__(self, bullet_velocity, delay, damage, ammo, max_ammo, reload_time, accuracy,
                           gun_x_position, gun_y_position, width, height, look_left_offset)

        self.rect = self.server_rect.get_pygame_rect()
        self.animation = Animation(image_list, self)
        self.image = self.animation.current_image()

#*************************************************************************************************
#*************************************************************************************************
#updates the image
#when gun is charging it will run the animation
    def update_weapon_image(self, player):
        if player.is_shooting:
            self.animation.use_image_at = 1
        else:
            self.animation.use_image_at = 0

        mouse_position = player.mouse_position
        gun_position_vector = get_vector_to_position(mouse_position, self.window_position_center)
        theta = self.roto_theta_conversion_tool_extreme(gun_position_vector) + 90
        if math.fabs(theta) > 90:
            image = pygame.transform.flip(self.animation.current_image(), 1, 0)
            self.image = pygame.transform.rotate(image, theta + 180)
            player.gun_is_pointed_right = False
        else:
            self.image = pygame.transform.rotate(self.animation.current_image(), theta)
            player.gun_is_pointed_right = True

        #set where the player is looking if they aren't dashing
        if not player.is_dashing:
                player.is_looking_right = player.gun_is_pointed_right

        if player.gun_is_pointed_right:
            self.set_center(euclid.Vector2(player.start_position.x + player.get_width() / 2.0 + self.gun_x_position,
                                           player.start_position.y + player.get_height() / 2.0 +
                                           self.gun_y_position))
        else:
            self.set_center(euclid.Vector2(player.start_position.x + player.get_width() / 2.0 + self.gun_x_position +
                                           self.look_left_offset, player.start_position.y + player.get_height() / 2.0 +
                                           self.gun_y_position))

        self.server_rect.reform_rect(self.image.get_width(), self.image.get_height(), self.server_rect.center)
        self.reset_rects()
        self.rect = self.server_rect.get_pygame_rect()

#*************************************************************************************************
#*************************************************************************************************
#returns a projectile that the Player shot
    def use_weapon(self, player):  # self is da gun

        current_time = now()
        bullet_position_vector = get_vector_to_position(player.mouse_position, self.window_position_center)
        time_since_fire = current_time - player.last_fire_time

        shot = []
        if time_since_fire >= self.delay and self.ammo > 0 and not player.is_reloading:
            #player shot
            self.calculate_end_of_barrel(player)
            player.is_shooting = True
            player.last_fire_time = current_time
            self.ammo -= 1
            for a in range(1, self.shoots_this_many_at_a_time + 1):
                shot.append(Projectile(
                    self.end_of_barrel, self, player,
                    euclid.Vector2((bullet_position_vector.x +
                                   random.uniform(-self.accuracy, self.accuracy)) *
                                   self.bullet_velocity,

                                   (bullet_position_vector.y +
                                    random.uniform(-self.accuracy, self.accuracy)) *
                                   self.bullet_velocity)))

            return shot
        return None
开发者ID:Final-Parsec,项目名称:The-Venom-Event-Prototype,代码行数:83,代码来源:gun.py


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