コード例 #1
0
ファイル: stages.py プロジェクト: pompshuffle/super-tilt-bro
	def serialize(self):
		"""
		Serialize platform in a string using Super Tilt Bro's assembly format
		"""
		# Hack horizontal values are caped to [1, 254] instead of [0, 255] to avoid a bug in STB engine
		return 'SMOOTH_PLATFORM({}, {}, {}) ; left, right, top\n'.format(
			uintasm8(max(1, self.left-7)), uintasm8(min(254, self.right)), uintasm8(self.top-15)
		)
コード例 #2
0
		def serialize(self):
			if self.size == 1:
				return 'ZIPZ,'
			else:
				serialized = ''
				rest = self.size
				while rest > 255:
					serialized += '$00,{}, '.format(uintasm8(255))
					rest -= 255
				if rest == 1:
					serialized += 'ZIPZ,'
				else:
					serialized += '$00,{}, '.format(uintasm8(rest))

				line_size = self.size * 5
				if len(serialized) < line_size:
					serialized += ' ' * (line_size - len(serialized))

				return serialized
コード例 #3
0
ファイル: nametables.py プロジェクト: clach04/super-tilt-bro
    def serialize(self):
        serialized = 'nametable_{}:\n'.format(self.name)

        compressed = self.get_compressed_tilemap()
        serialized += '.byt '
        position = 0
        line_num = 0
        for bytecode in compressed:
            # Align the bytecode horizontally
            #  5 characters per tile "len('$XX, ') == 5" + 1 character every 4 tiles (to separate by attribute byte)
            horizontal_align = position * 5 + (position // 4)
            current_align = len(serialized) - serialized.rfind('.byt ') - len(
                '.byt ')
            if current_align < horizontal_align:
                serialized += ' ' * (horizontal_align - current_align)

            # Serilize the bytecode
            position += bytecode.size
            serialized += bytecode.serialize()

            # Keep track of new lines
            while position >= 32:
                serialized = serialized.rstrip(', ')

                line_num += 1
                if line_num % 4 == 0:
                    serialized += '\n;    -------------------  -------------------  -------------------  -------------------  -------------------  -------------------  -------------------  -------------------'

                serialized += '\n.byt '
                position -= 32
        serialized += '\n'

        serialized += 'nametable_{}_attributes:\n'.format(self.name)
        for attributes_line in self.attributes:
            serialized += '.byt '
            for attributes_byte in attributes_line:
                attribute_int = (attributes_byte[0] << 6) + (
                    attributes_byte[1] << 4) + (
                        attributes_byte[2] << 2) + attributes_byte[3]
                serialized += '{}, '.format(uintasm8(attribute_int))
            serialized = serialized.rstrip(', ')
            serialized += '\n'

        serialized += 'nametable_{}_end:\n.byt ZIPNT_END\n'.format(self.name)

        return serialized
コード例 #4
0
	def serialize(self):
		return 'ANIM_SPRITE%s(%s, %s, %s, %s)\n' % ('_FOREGROUND' if self.foreground else '',intasm8(self.y), self.tile, uintasm8(self.attr), intasm8(self.x))
コード例 #5
0
	def serialize(self):
		return 'ANIM_HITBOX(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n' % (
			'$01' if self.enabled else '$00', uintasm8(self.damages), intasm16(self.base_h), intasm16(self.base_v), intasm16(self.force_h), intasm16(self.force_v), intasm8(self.left), intasm8(self.right), intasm8(self.top), intasm8(self.bottom)
		)
コード例 #6
0
ファイル: nametables.py プロジェクト: clach04/super-tilt-bro
 def serialize(self):
     return '{}, '.format(uintasm8(self.tilenum))