"""Analyze the Level sprite from the Scratch project to extract level data.""" import json d = json.load(open('extracted/project.json', encoding='utf-8')) # Find the Level sprite level_sprite = [t for t in d['targets'] if t['name'] == 'Level'][0] print("=== LEVEL SPRITE ANALYSIS ===") print(f"Number of costumes: {len(level_sprite['costumes'])}") print("\nCostume names (first 40):") for i, c in enumerate(level_sprite['costumes'][:40]): print(f" {i}: {c['name']} - {c.get('rotationCenterX', 0)}x{c.get('rotationCenterY', 0)}") print("\n=== LOCAL VARIABLES ===") for k, v in level_sprite.get('variables', {}).items(): print(f" {v}") print("\n=== LOCAL LISTS ===") for k, v in level_sprite.get('lists', {}).items(): print(f" {v[0]}: {len(v[1])} items") if len(v[1]) > 0: print(f" First 20: {v[1][:20]}") # Look at the blocks for level loading logic print("\n=== SEARCHING FOR LEVEL POSITIONING CODE ===") blocks = level_sprite.get('blocks', {}) print(f"Total blocks: {len(blocks)}") # Look for blocks that might position the level tiles for block_id, block in blocks.items(): opcode = block.get('opcode', '') if 'costume' in opcode.lower() or 'clone' in opcode.lower() or 'position' in opcode.lower(): print(f" {opcode}: {block}") break # Check stage variables for level data stage = [t for t in d['targets'] if t['isStage']][0] print("\n=== STAGE LISTS (potential level data) ===") for k, v in stage.get('lists', {}).items(): name = v[0] data = v[1] print(f" {name}: {len(data)} items") if 'level' in name.lower() or 'jump' in name.lower() or 'x' in name.lower(): print(f" Data sample: {data[:30]}")