Example #1
0
    def __init__(self, game):

        # stand right
        self.stand_right = image.load('role/role-rightwards.png')
        # stand left
        self.stand_left = image.load('role/role-leftwards.png')
        # stand image
        self.image_stand = self.stand_right

        # walk right
        rframe_stand = image.AnimationFrame(
            image.load('role/role-rightwards.png'), 0.15)
        rframe_walk = image.AnimationFrame(
            image.load('role/role_walk-rightwards.png'), 0.15)
        self.rframes_walk = image.Animation([rframe_stand, rframe_walk])
        # walk left
        lframe_stand = image.AnimationFrame(
            image.load('role/role-leftwards.png'), 0.15)
        lframe_walk = image.AnimationFrame(
            image.load('role/role_walk-leftwards.png'), 0.15)
        self.lframes_walk = image.Animation([lframe_stand, lframe_walk])
        # walk frame
        self.frames_walk = self.rframes_walk

        # jump right
        rframe_jump = image.load('role/role_jump-rightwards.png')
        self.rframs_jump = rframe_jump
        # jump left
        lframe_jump = image.load('role/role_jump-leftwards.png')
        self.lframs_jump = lframe_jump
        # jump image
        self.image_jump = rframe_jump

        # dead right
        right_dead = image.load('role/role_dead-rightwards.png')
        self.right_dead = right_dead
        # dead left
        left_dead = image.load('role/role_dead-leftwards.png')
        self.left_dead = left_dead
        # dead image
        self.image_dead = self.right_dead

        # init
        super(Role, self).__init__(self.image_stand)
        self.image_anchor = 0, 0
        self.scale = 0.3
        self.position = 100, 300
        self.game = game

        self.can_shot = True
        self.can_jump = False
        self.direction = "RIGHT"
        self.state = "STAND"
        self.speed = 0
        self.dead = False

        self.schedule(self.update)
Example #2
0
 def get_sprite(self):
     l = []
     l.append(image.AnimationFrame(image.load('pic/1.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/2.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/3.png'), 0.1))
     images = image.Animation(l)
     self.sprite = Sprite(images)
     self.sprite.scale = 0.5
     self.add(self.sprite)
Example #3
0
 def get_sprite(self):
     l = []
     l.append(image.AnimationFrame(image.load('pic/b001.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/b002.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/b003.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/b004.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/b005.png'), 0.1))
     l.append(image.AnimationFrame(image.load('pic/b006.png'), 0.1))
     images = image.Animation(l)
     self.sprite = Sprite(images)
     self.add(self.sprite)
Example #4
0
    def __init__(self, game):

        frame_1 = image.AnimationFrame(image.load('ppx1.png'), 0.15)
        frame_2 = image.AnimationFrame(image.load('ppx2.png'), 0.15)
        self.frames = image.Animation([frame_1, frame_2])
        frame_rush_1 = image.AnimationFrame(image.load('ppx_rush1.png'), 0.15)
        frame_rush_2 = image.AnimationFrame(image.load('ppx_rush2.png'), 0.15)
        self.frames_rush = image.Animation([frame_rush_1, frame_rush_2])
        super(PPX, self).__init__(self.frames)

        self.sound_rush = pygame.mixer.Sound("rush.wav")
        self.sound_die = pygame.mixer.Sound("die.wav")
        self.sound_jump = pygame.mixer.Sound("jump.wav")

        self.game = game
        self.dead = False
        self.can_jump = False
        self.speed = 0
        self.rush_time = 0
        self.velocity = 0
        self.image_anchor = 0, 0
        self.position = 100, 300
        self.schedule(self.update)
Example #5
0
 def __init__(self, _image, center_x, center_y, radius):
     # super(CollidableAnimatingSprite, self).__init__(common.load_image(image+".gif"))
     # 用png去模拟gif效果
     super(CollidableAnimatingSprite,
           self).__init__(common.load_image(_image + "0.png"))
     actionimage1 = image.AnimationFrame(
         common.load_image(_image + "0.png"), 0.1)
     actionimage2 = image.AnimationFrame(
         common.load_image(_image + "1.png"), 0.1)
     actionimage3 = image.AnimationFrame(
         common.load_image(_image + "2.png"), 0.1)
     actionimage = image.Animation(
         [actionimage1, actionimage2, actionimage3])
     self.image = actionimage
     self.position = (center_x, center_y)
     self.cshape = CircleShape(Vector2(center_x, center_y), radius)
     self.name = image
     self.gravity = 0
     self.velocity = (0, 0)
     self.do(Move())