Ejemplo n.º 1
0
    def __init__(self):
        super(SpriteLayer, self).__init__()

        sprite1 = Sprite("grossini.png")
        sprite2 = Sprite("grossinis_sister1.png")
        sprite3 = Sprite("grossinis_sister2.png")

        sprite1.position = (320, 240)
        sprite2.position = (620, 100)
        sprite3.position = (20, 100)

        self.add(sprite1)
        self.add(sprite2)
        self.add(sprite3)

        ju_right = JumpBy((600, 0), height=100, jumps=4, duration=5)
        ju_left = JumpBy((-600, 0), height=100, jumps=4, duration=5)
        rot1 = Rotate(180 * 4, duration=5)

        sprite1.opacity = 128

        sc = ScaleBy(9, 5)
        rot = Rotate(180, 5)

        sprite1.do(Repeat(sc + Reverse(sc)))
        sprite1.do(Repeat(rot + Reverse(rot)))
        sprite2.do(Repeat(ju_left + Reverse(ju_left)))
        sprite2.do(Repeat(Reverse(rot1) + rot1))
        sprite3.do(Repeat(ju_right + Reverse(ju_right)))
        sprite3.do(Repeat(rot1 + Reverse(rot1)))
Ejemplo n.º 2
0
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        sprite1 = Sprite('grossini.png')
        sprite1.position = x//4, y//2
        self.add( sprite1 )

        sprite2 = Sprite('grossini.png')
        sprite2.position = x//4, y//2
        self.add( sprite2, z=2  )
        sprite2.scale = 0.3

        sprite2.do( RotateBy(duration=2, angle=360) )
        sprite1.do( RotateBy(duration=2, angle=-360) )

        sprite1.transform_anchor = 0, 0

        sprite3 = Sprite('grossini.png')
        sprite3.position = 3*x//4, y//2
        self.add( sprite3  )

        sprite4 = Sprite('grossini.png')
        sprite4.position = 3*x//4, y//2
        self.add( sprite4, z=2  )
        sprite4.scale = 0.3

        sprite3.do( RotateBy(duration=2, angle=360) )
        sprite4.do( RotateBy(duration=2, angle=-360) )

        sprite3.transform_anchor = sprite3.image.width//2, sprite3.image.height//2
Ejemplo n.º 3
0
Archivo: room.py Proyecto: spookyy/hss
    def __init__(self, sock):
        super(Room, self).__init__()
        
        self.sock = sock
        
        self.image1 = pyglet.resource.image('qiuqiu.jpg')
        self.image1.anchor_x = self.image1.width/2
        self.image1.anchor_y = self.image1.height/2
        sprite1 = Sprite(self.image1)
        self.add(sprite1, z=0, name="qiuqiu")
        sprite1.position = 220, 240
        
        self.image2 = pyglet.resource.image('heishen.jpg')
        self.image2.anchor_x = self.image2.width/2
        self.image2.anchor_y = self.image2.height/2
        sprite2 = Sprite(self.image2)
        self.add(sprite2, z=0, name="heishen")
        sprite2.position = 420, 240
        
        label = cocos.text.Label('Pick one? Click He or She!',
            font_name='liberationmono',
            font_size=16,
            anchor_x='center', anchor_y='center')

        label.position = 320, 80
        self.add( label )
Ejemplo n.º 4
0
    def _create_sprites(self):
        SPEED = 0.4

        logo_image = common.load_image('scene/intro/ceferino.png')
        logo = Sprite(logo_image)
        logo.scale = 4
        logo.rotation = 180
        logo.opacity = 0
        logo.do(Place((100, 230)))
        logo.do(Delay(SPEED / 2) + 
                (FadeIn(SPEED * 2) | RotateBy(180, SPEED) | ScaleTo(1, SPEED)))

        losers_image = common.load_image('scene/intro/losers.png')
        losers = Sprite(losers_image)
        losers.position = 300, 500
        losers.rotation = 180
        losers.opacity = 0
        losers.do(Delay(SPEED) + 
                (MoveTo((300, 250), SPEED) | FadeIn(SPEED) | RotateBy(180, SPEED)))

        juegos_image = common.load_image('scene/intro/juegos.png')
        juegos = Sprite(juegos_image)
        juegos.position = 500, 0
        juegos.rotation = -180
        juegos.opacity = 0
        juegos.do(Delay(SPEED/2 * 3) +
                (MoveTo((520, 250), SPEED) | FadeIn(SPEED) | RotateBy(180, SPEED))
                + Delay(2) + CallFunc(self.skip_scene))

        self.add(logo)
        self.add(losers)
        self.add(juegos)
        self.juegos = juegos
Ejemplo n.º 5
0
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        parent = Sprite('grossinis_sister1.png')
        self.add( parent )
        parent.position = ( x/2, y/2 )

        sprite = Sprite('grossinis_sister2.png')
        sprite.position = 100,140
        sprite.do( RotateBy( duration=2, angle=360 ) )
        sprite.do( ScaleBy( duration=2, scale=2 ) )
        sprite.do( MoveBy( duration=2, delta=(200,0) ) )
        parent.add( sprite )
        sprite.opacity = 128
        self.sprite1 = sprite

        sprite = Sprite('grossini.png')
        self.add( sprite )
        sprite.position = 100,140
        sprite.do( RotateBy( duration=2, angle=360 ) )
        sprite.do( ScaleBy( duration=2, scale=2 ) )
        sprite.do( MoveBy( duration=2, delta=(200,0) ) )

        self.sprite2 = sprite
Ejemplo n.º 6
0
    def on_enter( self ):
        super(SpriteReuseAction,self).on_enter()
        sprite1 = Sprite( self.image_sister1)
        sprite2 = Sprite( self.image_sister2)

        self.add( sprite1 )
        self.add( sprite2 )
        sprite1.position = 120,250
        sprite2.position = 20,100

        jump = JumpBy( (400,0), 150, 4, 4 )
        sprite1.do( jump )
        sprite2.do( jump )
    def __init__( self ):
        super( SpriteLayer, self ).__init__()

        sprite1 = Sprite( 'grossini.png' )
        sprite2 = Sprite( 'grossinis_sister1.png')
        sprite3 = Sprite( 'grossinis_sister2.png')

        sprite1.position = (400,240)
        sprite2.position = (300,240)
        sprite3.position = (500,240)

        self.add( sprite1 )
        self.add( sprite2 )
        self.add( sprite3 )
Ejemplo n.º 8
0
    def __init__( self ):
        super( GrossiniLayer2, self ).__init__()

        rot = Rotate( 360, 5 )
        g1 = Sprite( 'grossinis_sister1.png' )
        g1.position = (490,240)

        g2 = Sprite( 'grossinis_sister2.png' )
        g2.position = (140,240)

        g1.do( Repeat( rot + Reverse(rot) ) )
        g2.do( Repeat( rot + Reverse(rot) ) )

        self.add( g1 )
        self.add( g2 )
Ejemplo n.º 9
0
    def on_enter( self ):
        super(SpriteRepeatAlterTime,self).on_enter()
        sprite1 = Sprite( self.image_sister1 )
        sprite2 = Sprite( self.image_sister2 )

        self.add( sprite1 )
        self.add( sprite2 )
        sprite1.position = (20,100)
        sprite2.position = (20,300)

        action  = MoveBy( (500,0), 3 )
        move1 = Accelerate( action )
        move2 = action
        sprite1.do( Repeat(move1+Reverse(move1)) )
        sprite2.do( Repeat(move2+ Reverse(move2)) )
Ejemplo n.º 10
0
    def __init__(self):
        super(GameScene, self).__init__()


        self.dimension = 616
        self.position = 76, 348


        track_sprite = Sprite('images/track.png')
        track_sprite.position = self.dimension/2, 27
        self.add( track_sprite, z=1 )


        # paddle
        self.paddle = Paddle(self.dimension, self.dimension, 27)
        self.add( self.paddle.sprite, z=2)


        # ball and movement
        self.ball_movement = BounceBoundedMove(self.dimension, self.dimension, 10)
        self.ball = CollidableRectSprite("images/ball.png", self.dimension/2, self.dimension/2)
        self.add(self.ball, z=10)
        self.ball.velocity = (200, 136)
        self.ball.do(self.ball_movement)

        self.do(GameClock(10000))

        self.collision = cm.CollisionManagerBruteForce();
        self.collision.add(self.paddle.sprite)
        self.collision.add(self.ball)
Ejemplo n.º 11
0
    def __init__(self):
        super( TestLayer, self ).__init__(0,0,50,255)

        # get the sizes
        sprite = Sprite('fire.png')
        w, h =  sprite.width/2, sprite.height/2

        # thes are the center of the sprites, where to click
        self.positions = [
            (w, h),
            (sw-w, h),
            (w, sh-h),
            (sw-w, sh-h),
            (sw//2, sh//2),
        ]

        # let's draw the sprites
        self.sprites = []
        for pos in self.positions:
            sprite = Sprite('fire.png')
            sprite.position = pos
            self.add(sprite)
            self.sprites.append(sprite)

        self.dd = sprite
Ejemplo n.º 12
0
	def gamestart(self):
		self.update_hud()
		self.paddle.reset()
		self.ball.reset()

		# 添加砖块并且显示出来
		# 先删除残存的砖块
		for b in self.blocks:
			self.remove(b)
		# 再初始化新的砖块
		self.blocks = []
		self.level += 1
		self.hud2.element.text = 'Level:' + str(self.level)
		if self.level > 4:
			self.level = 1
		levelfile = 'level' + str(self.level) + '.txt'
		positions = level_from_file(levelfile)
		number_of_blocks = len(positions)
		for i in range(number_of_blocks):
			b = Sprite('images/zhuan.png', anchor=(0, 0))
			b.position = positions[i]
			# b.color = (randint(0, 255), randint(0, 255), randint(0, 255))
			# b.position = (randint(0, 500), 400)
			self.add(b)
			self.blocks.append(b)
Ejemplo n.º 13
0
 def __init__(self):
     super(TitleLayer, self).__init__()
     w, h = director.get_window_size()
     logo = Sprite('Moon_1.jpg')
     lh = logo.height
     logo.position = (w//2, h//2)
     self.add(logo)
Ejemplo n.º 14
0
	def __init__(self, color="blue", vision=False):
		super().__init__()

		# create and add Sprites for ghost
		self.ghost1 = Sprite("images/" + color + "1.png")
		self.ghost2 = Sprite("images/" + color + "2.png")
		self.eyes = Sprite("images/eyesDown.png")

		self.sprites.append(self.ghost1)
		self.sprites.append(self.ghost2)
		self.sprites.append(self.eyes)

		self.charRect = Rect(40, 40, self.ghost1.width * 0.12, self.ghost1.height * 0.12)
		self.charRect.center = (40, 40);

		for ghost in self.sprites:
			self.add(ghost)
			ghost.position = self.charRect.center
			ghost.scale = 0.12


		# if this is my player add a vision field
		if vision:
			visionSprite = Sprite("images/vision.png")
			self.sprites.append(visionSprite)
			self.add(visionSprite)
			visionSprite.position = self.charRect.center


		# Animate ghost
		self.ghost1.do(Repeat(Blink(1, 0.3)))
Ejemplo n.º 15
0
    def draw( self ):
        super(GameCtrl, self).draw()

        glLoadIdentity()

        bodies = self.model.world.GetBodyList()
        i = 0
        for b in bodies:
            props = b.GetUserData()
            if not props:
                continue
            sprite = props.get_sprite()
            if not sprite:
                if props.isCharacter:
                    sprite = Sprite(self.image)
                elif props.isBlock:
                    shape = b.GetShapeList()[0]
                    vertices = shape.getVertices_b2Vec2()
                    sprite = RectBlock(vertices)
                    print sprite.p1, sprite.p2, sprite.p3, sprite.p4
                else:
                    continue

            props.set_sprite(sprite)
            self.add(sprite)
            sprite.position = (b.position.x * self.model.zoom), \
                (b.position.y * self.model.zoom)
            degrees = -(b.GetAngle() * 180) / math.pi
            sprite.rotation = degrees

        # center the image
        glTranslatef(-320, -240, -320.0)
Ejemplo n.º 16
0
    def __init__(self, life=100, bullets=100):
        super(HudLayer, self).__init__()

        x, y = director.get_window_size()

        self.bullets_ico = face = Sprite('hud/bullets.png')
        self.bullets_ico.position = (
            self.bullets_ico.image.width/2,
            self.bullets_ico.image.height/2
        )

        self.bullets_label = cocos.text.Label(str(bullets),
            font_name='Times New Roman',
            font_size=32,
            x=self.bullets_ico.image.width+10,
            y=self.bullets_ico.image.height/2,
            anchor_x='left', anchor_y='center')
        self.add(self.bullets_ico)
        self.add(self.bullets_label)

        self.faces = {}
        self.deads = []
        space = 0
        self.face_scale = scale = 0.7
        for who in ["Dad", "Mom", "Zack", "Bee"]:
            sprite = Sprite('faces/%s.png'%who)
            self.faces[who] = sprite
            sprite.scale = scale
            sprite.position = (
                x-space-sprite.image.width*scale/2,
                sprite.image.height*scale/2
            )
            space += sprite.image.width*scale + 10

            self.add(sprite)
Ejemplo n.º 17
0
    def on_enter( self ):
        super(SpriteFadeOut,self).on_enter()
        sprite1 = Sprite( self.image_sister1)
        sprite2 = Sprite( self.image_sister2)

        self.add( sprite1 )
        self.add( sprite2 )
        sprite1.position = 200,240
        sprite2.position = 440,240

        fadeout = FadeOut( 2 )
        fadein = FadeIn( 2 )

        sprite1.opacity = 0
        sprite1.do( fadein )
        sprite2.do( fadeout )
Ejemplo n.º 18
0
    def _add_indicator(self, indicator_name, indicator_img):
        indicator = Sprite(indicator_img)
        indicator.position = self.position

        self.add(indicator, z=len(self.indicators))

        self.indicators[indicator_name] = indicator
Ejemplo n.º 19
0
    def on_enter( self ):
        super(SpriteAlterTime,self).on_enter()
        sprite1 = Sprite( self.image_sister1 )
        sprite2 = Sprite( self.image_sister2 )

        self.add( sprite1 )
        self.add( sprite2 )

        sprite1.position = 20,100
        sprite2.position = 20,300

        move1 = MoveBy( (500,0), 3 )
        move2 = Accelerate( MoveBy( (500,0), 3 ) )

        sprite1.do( move1 )
        sprite2.do( move2 )
Ejemplo n.º 20
0
    def on_enter( self ):
        super(SpriteMoveTo,self).on_enter()

        sprite3 = Sprite( self.image )
        self.add(sprite3)
        sprite3.position = 320,300
        sprite3.do( MoveTo( (620,300), 4 ) )
Ejemplo n.º 21
0
    def draw( self ):
        super(cocos_box2d_layer,self).draw()

        glLoadIdentity()

        bodies = self.world.GetBodyList()
        i = 0
        for b in bodies:
            userdata = b.GetUserData()
            if not userdata:
                userdata = {}
                b.SetUserData(userdata)
            sprite = userdata.get("sprite")
            if not sprite:
                if userdata.get("sister1"):
                    sprite = Sprite(self.image_sister1)
                elif userdata.get("sister2"):
                    sprite = Sprite(self.image_sister2)
                else:
                    sprite = Sprite(self.image)
                self.add(sprite)
                userdata["sprite"] = sprite

            sprite.position = (b.position.x * self.zoom), (b.position.y * self.zoom)
            degrees = (b.GetAngle() * 180) / math.pi
            sprite.rotation = degrees

        # center the image
        glTranslatef(-320, -240, -320.0)
Ejemplo n.º 22
0
 def add_body(self):
     b = Sprite('circle.png', color=self.color)
     b.scale = 1.5
     self.body.append(b)
     if self.x == 0:
         print self.position
     b.position = self.position
     self.parent.batch.add(b, 9999 - len(self.body))
Ejemplo n.º 23
0
    def __init__(self):
        super( TestLayer, self ).__init__()
        
        x,y = director.get_window_size()
        
        sprite1 = Sprite('grossini.png')
        sprite1.position = x/2, y/2
        sprite1.children_anchor = 0,-100
        self.add( sprite1  )

        sprite2 = Sprite('grossini.png')
        sprite2.position = 50,0
        sprite1.add( sprite2  )

        sprite3 = Sprite('grossini.png')
        sprite3.position = -50,0
        sprite1.add( sprite3 )
Ejemplo n.º 24
0
    def on_enter( self ):
        super(SpriteScale,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = 320,200

        sprite.do( ScaleTo( 10, 5 ) )
Ejemplo n.º 25
0
    def __init__(self):
        super( Monster, self ).__init__()

        self.ww = director.window.width
        self.wh = director.window.height

        sprite = Sprite('images/spaceship.gif')
        sprite.position = 320,240
        self.add( sprite, z=1 )
Ejemplo n.º 26
0
    def on_enter( self ):
        super(SpriteTrigger,self).on_enter()
        sprite = Sprite( self.image)
        self.add( sprite )
        sprite.position = 120,100
        
        move = MoveBy( (100,0), 2 )

        sprite.do( move + CallFunc( self.say_hello )  )
Ejemplo n.º 27
0
    def on_enter( self ):
        super(SpriteRepeat2,self).on_enter()
        sprite = Sprite( self.image)

        self.add( sprite )
        sprite.position = 120,100
        
        jump = JumpBy( (400,0), 100,4,3 )

        sprite.do( Repeat( jump + Reverse( jump ) ) )
Ejemplo n.º 28
0
    def on_enter( self ):
        super(SpriteRepeat,self).on_enter()
        sprite = Sprite( self.image)

        self.add( sprite )
        sprite.position = 120,100

        jump = JumpBy((400,0),100,4,3)

        sprite.do( Repeat( Place((120,100)) + jump ) )
Ejemplo n.º 29
0
    def on_enter( self ):
        super(SpriteBlink,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = (320,240)

        blink = Blink( 10, 2 )

        sprite.do( blink )
Ejemplo n.º 30
0
    def on_enter( self ):
        super(SpriteSpawn,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = 120,100

        jump = JumpBy( (400,0),100,4,5)
        rotate = RotateBy( 720, 5 )
        sprite.do( jump | rotate )
Ejemplo n.º 31
0
    def say_hello(self):
        print("HELLO BABY")

        sprite2 = Sprite(self.image_sister1)
        self.add(sprite2)
        sprite2.position = 270, 110
Ejemplo n.º 32
0
 def add_sprite(self, image, position):
     sprite = Sprite(image)
     sprite.position = position
     self.add(sprite)
Ejemplo n.º 33
0
    def updatePlayerUnitStats(self, battle_unit):
        if self.unit_display is not None:
            self.unit_display.kill()
            self.unit_name.kill()
            self.unit_variant.kill()
            self.unit_stats.kill()
            self.unit_values.kill()

        if battle_unit is None:
            # Hide player unit stats at bottom left
            self.unit_display = None
            self.unit_name = None
            self.unit_variant = None
            self.unit_stats = None
            self.unit_values = None
            return

        size = director.get_window_size()
        width = size[0]
        height = size[1]

        self.unit_display = BatchNode()
        self.unit_display.position = 0, 0

        mech_img_grid = pyglet.image.ImageGrid(
            pyglet.resource.image(battle_unit.getImagePath()), 1, 6)
        mech_img_static = mech_img_grid[0]
        pitch = -(mech_img_static.width * len('RGBA'))
        img_data = mech_img_static.get_image_data()

        # testing with masking only a portion of the image
        damage_height = int(
            mech_img_static.height)  # int(mech_img_static.height * 0.67)
        data = img_data.get_region(0, 0, mech_img_static.width,
                                   damage_height).get_data('RGBA', pitch)

        mask = Image.frombytes('RGBA', (mech_img_static.width, damage_height),
                               data)
        # the first image is the color that the stamp will be
        img1 = Image.new('RGBA', mask.size, color=(0, 0, 0, 255))
        # second image is the background
        img2 = Image.new('RGBA', mask.size, color=(225, 225, 225, 200))
        img1 = img1.convert('RGBA')

        # apply mask to background image
        img = Image.composite(img1, img2, mask)

        raw_image = img.tobytes()
        img_x = mask.size[0]
        img_y = mask.size[1]
        pyg_img = pyglet.image.ImageData(img_x,
                                         img_y,
                                         'RGBA',
                                         raw_image,
                                         pitch=-img_x * len('RGBA'))

        mech_sprite = Sprite(pyg_img)
        mech_sprite.position = Board.TILE_SIZE // 2 + mech_sprite.width // 2, \
                               Board.TILE_SIZE + mech_sprite.height // 2

        self.unit_display.add(mech_sprite)
        self.add(self.unit_display)

        # Show unit name above the image
        self.unit_name = floaters.TextFloater(battle_unit.getName(),
                                              font_name='TranscendsGames',
                                              font_size=Board.TILE_SIZE // 2,
                                              anchor_x='left',
                                              anchor_y='bottom')
        self.unit_name.position = Board.TILE_SIZE // 2, mech_sprite.get_rect(
        ).topleft[1]
        self.add(self.unit_name)

        # Show unit variant below the image
        self.unit_variant = floaters.TextFloater(
            battle_unit.getVariant().upper(),
            font_name='TranscendsGames',
            font_size=Board.TILE_SIZE // 3,
            anchor_x='left',
            anchor_y='top')

        self.unit_variant.position = Board.TILE_SIZE // 2, Board.TILE_SIZE - 4
        self.add(self.unit_variant)

        # Show armor, structure, heat stats next to the image (top)
        self.unit_stats = UnitStats(battle_unit)
        stats_pos = mech_sprite.get_rect().topright
        self.unit_stats.position = 4 + stats_pos[0], stats_pos[
            1] - self.unit_stats.height
        self.add(self.unit_stats)

        # Show move and attack numbers next to the image (bottom)
        values = "MV %i  ATK %i/%i/%i" % (battle_unit.getTurnMove(),
                                          battle_unit.short,
                                          battle_unit.medium, battle_unit.long)
        self.unit_values = floaters.TextFloater(values,
                                                font_name='TranscendsGames',
                                                font_size=Board.TILE_SIZE // 4,
                                                anchor_x='left',
                                                anchor_y='bottom')
        values_pos = mech_sprite.get_rect().bottomright
        self.unit_values.position = 4 + values_pos[0], values_pos[1] - 2
        self.add(self.unit_values)
Ejemplo n.º 34
0
    def __init__(self, battle_unit, reverse=False):
        super(UnitStats, self).__init__()

        self.reverse = reverse
        self.width = 0
        self.height = 0

        # create heat icon and bars
        heat_icon = Sprite(Resources.heat_icon_img)
        if reverse:
            heat_icon.position = -heat_icon.width // 2, self.height + heat_icon.height // 2
        else:
            heat_icon.position = heat_icon.width // 2, self.height + heat_icon.height // 2
        self.add(heat_icon, z=2)

        # TESTING: Use actual heat!!!
        rand_heat = random.randint(0, 4)
        for i in range(rand_heat):
            pip = Sprite(Resources.heat_pip_img)
            pip.scale = 2.0
            if reverse:
                pip.position = -heat_icon.width - (
                    i * pip.width) - pip.width, self.height + pip.height // 2
            else:
                pip.position = heat_icon.width + (
                    i *
                    pip.width) + pip.width // 2, self.height + pip.height // 2
            self.add(pip, z=1)

            if pip.x + pip.width > self.width:
                self.width = pip.x + pip.width

        self.height += 8

        # create structure icon and bars
        structure_icon = Sprite(Resources.structure_icon_img)
        if reverse:
            structure_icon.position = -structure_icon.width // 2, self.height + structure_icon.height // 2
        else:
            structure_icon.position = structure_icon.width // 2, self.height + structure_icon.height // 2
        self.add(structure_icon, z=2)

        orig_structure = battle_unit.mech.structure
        for i in range(orig_structure):
            pip_img = Resources.structure_pip_img
            if i >= battle_unit.structure:
                pip_img = Resources.empty_pip_img

            pip = Sprite(pip_img)
            pip.scale = 2.0
            if reverse:
                pip.position = -structure_icon.width - (
                    i * pip.width) - pip.width, self.height + pip.height // 2
            else:
                pip.position = structure_icon.width + (
                    i *
                    pip.width) + pip.width // 2, self.height + pip.height // 2
            self.add(pip, z=1)

            if pip.x + pip.width > self.width:
                self.width = pip.x + pip.width

        self.height += 8

        # create armor icon and bars
        armor_icon = Sprite(Resources.armor_icon_img)
        if reverse:
            armor_icon.position = -armor_icon.width // 2, self.height + armor_icon.height // 2
        else:
            armor_icon.position = armor_icon.width // 2, self.height + armor_icon.height // 2
        self.add(armor_icon, z=2)

        orig_armor = battle_unit.mech.armor
        for i in range(orig_armor):
            pip_img = Resources.armor_pip_img
            if i >= battle_unit.armor:
                pip_img = Resources.empty_pip_img

            pip = Sprite(pip_img)
            pip.scale = 2.0
            if reverse:
                pip.position = -armor_icon.width - (
                    i * pip.width) - pip.width, self.height + pip.height // 2
            else:
                pip.position = armor_icon.width + (
                    i *
                    pip.width) + pip.width // 2, self.height + pip.height // 2
            self.add(pip, z=1)

            if pip.x + pip.width > self.width:
                self.width = pip.x + pip.width

        self.height += 8