Game Plugin

The Game plugin extends the base Game class with game-specific functionality.

Plugin Package Structure

A Game plugin package contains:

  • Plugin definition file

  • Game-specific Game subclass

  • Game-specific GameAPI subclass

  • Game sprites

Game Subclass Implementation

Most critical functionality comes from the parent Game class. The subclass provides game-specific configuration.

Required Components

class BluetangMyGame(Game, metaclass=Singleton):
    def __init__(self, **kwargs):
        kwargs["platform"] = "steam"
        kwargs["window_name"] = "My Game"
        kwargs["app_id"] = "123456"
        
        super().__init__(**kwargs)
        
        self.api_class = MyGameAPI
        self.api_instance = None

Screen Regions

Define regions of interest:

@property
def screen_regions(self):
    return {
        "MAIN_MENU_NEW_GAME": (626, 348, 708, 428),
        "MAIN_MENU_LOAD_GAME": (626, 429, 708, 510),
        "GAME_PAUSE_BUTTON": (0, 0, 27, 30),
        "GAME_SPEED_BUTTON": (0, 30, 27, 60)
    }

OCR Presets

Configure text recognition settings:

@property
def ocr_presets(self):
    return {
        "MENU_TEXT": {
            "extract": {
                "gradient_size": 3,
                "closing_size": 10
            },
            "perform": {
                "scale": 16,
                "order": 3,
                "horizontal_closing": 1,
                "vertical_closing": 1
            }
        }
    }

GameAPI Implementation

The GameAPI subclass contains reusable game-specific functions in files/api/api.py

Function Categories

  • UI operations

  • Game state management

  • Sprite detection

  • Data processing

Namespacing

class CombatAPI:
    def attack(self):
        pass
        
class InventoryAPI:
    def equip_item(self):
        pass

Game Sprites

Directory Structure

Place sprites in files/data/sprites using PNG format.

Naming Convention

sprite_<label>_<animation_state_index>.png

Examples: * `sprite_npc_priest_0.png` → SPRITE_NPC_PRIEST * `sprite_npc_priest_1.png` → Additional frame for SPRITE_NPC_PRIEST

Last updated