### Playgama Bridge Configuration Schema Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Example of the playgama-bridge-config.json file used to define platform-specific settings, advertisement behavior, and general SDK configuration. ```json { "$schema": "https://bridge.playgama.com/v1/stable/schema.json", "device": { "useBuiltInOrientationPopup": true, "supportedOrientations": ["landscape", "portrait"] }, "platforms": { "game_distribution": { "gameId": "your-game-id" }, "telegram": { "adsgramBlockId": "your-adsgram-block-id" }, "yandex": { "useSignedData": false, "sendAnalyticsEvents": false }, "crazy_games": { "xsollaProjectId": "", "isSandbox": false, "useUserToken": false } }, "advertisement": { "banner": {}, "interstitial": { "preloadOnStart": true }, "rewarded": { "preloadOnStart": true }, "useBuiltInErrorPopup": true, "backfillId": "" }, "payments": [], "leaderboards": [], "sendAnalyticsEvents": true } ``` -------------------------------- ### Get Product Catalog (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves the list of available products for purchase using `playgama_bridge_payments_get_catalog()`. The callback parses the JSON data and populates a global shop items array. ```gml // Get catalog of purchasable items playgama_bridge_payments_get_catalog(); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_payments_get_catalog_callback") { if (async_load[? "success"]) { var catalog = json_parse(async_load[? "data"]); global.shop_items = []; for (var i = 0; i < array_length(catalog); i++) { var product = { id: catalog[i].id, price: catalog[i].price, currency: catalog[i].priceCurrencyCode, price_value: catalog[i].priceValue }; array_push(global.shop_items, product); show_debug_message("Product: " + product.id + " - " + product.price); } } } ``` -------------------------------- ### Send Platform Message in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Sends a message to the platform, commonly used to signal game state changes. Examples include 'game_ready', 'gameplay_start', and 'gameplay_stop'. ```gml // Signal to the platform that the game has finished loading playgama_bridge_platform_send_message("game_ready", "{}"); // Send gameplay started message playgama_bridge_platform_send_message("gameplay_start", "{}"); // Send gameplay stopped message playgama_bridge_platform_send_message("gameplay_stop", "{}"); ``` -------------------------------- ### Get Server Time in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Requests the current server time from the platform. The result is received asynchronously via the Social Async event. ```gml // Request server time playgama_bridge_platform_get_server_time(); // Handle callback in Social Async event (Other_70.gml) if (async_load[? "type"] == "playgama_bridge_platform_get_server_time_callback") { if (async_load[? "success"]) { var server_time = async_load[? "data"]; show_debug_message("Server time: " + string(server_time)); } } ``` -------------------------------- ### Show Rewarded Ad Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Displays a rewarded video advertisement, allowing players to receive rewards after watching the complete video. The code includes examples for checking support, showing the ad, and handling various states including the 'rewarded' state. ```gml // Show rewarded ad with placement identifier playgama_bridge_advertisement_show_rewarded("double_coins"); // Check support before showing var is_supported = playgama_bridge_advertisement_is_rewarded_supported(); if (is_supported == "1") { playgama_bridge_advertisement_show_rewarded("extra_life"); } // Handle state changes in Social Async event (Other_70.gml) if (async_load[? "type"] == "playgama_bridge_advertisement_rewarded_state_changed") { switch (async_load[? "data"]) { case "loading": show_debug_message("Rewarded ad loading..."); break; case "opened": audio_master_gain(0); game_set_speed(0, gamespeed_fps); break; case "closed": audio_master_gain(1); game_set_speed(60, gamespeed_fps); break; case "rewarded": // Grant the reward to the player global.coins += 100; show_debug_message("Reward granted!"); break; case "failed": show_debug_message("Rewarded ad failed"); break; } } ``` -------------------------------- ### Get Player Purchases (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves a list of purchases made by the current player using `playgama_bridge_payments_get_purchases()`. This is used for restoring purchases and handles the callback to process the purchase data. ```gml // Get player's purchases (for restoring purchases) playgama_bridge_payments_get_purchases(); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_payments_get_purchases_callback") { if (async_load[? "success"]) { var purchases = json_parse(async_load[? "data"]); for (var i = 0; i < array_length(purchases); i++) { var product_id = purchases[i].id; // Restore purchase if (product_id == "remove_ads") { global.ads_removed = true; } } } } ``` -------------------------------- ### Get Platform ID in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves the identifier of the current platform where the game is running. This is useful for implementing platform-specific logic using a switch statement. ```gml // Get the current platform identifier var platform_id = playgama_bridge_platform_id(); show_debug_message("Running on platform: " + platform_id); // Platform-specific logic switch (platform_id) { case "yandex": // Yandex Games specific setup break; case "telegram": // Telegram specific setup break; case "crazy_games": // Crazy Games specific setup break; default: // Default behavior break; } ``` -------------------------------- ### Get Platform Payload in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves any payload data passed to the game, typically via URL parameters or deep linking. The payload is expected to be a JSON string. ```gml // Get launch payload (e.g., invite links, referral codes) var payload = playgama_bridge_platform_payload(); if (payload != "null" && payload != "") { var payload_data = json_parse(payload); if (variable_struct_exists(payload_data, "invite_code")) { global.invite_code = payload_data.invite_code; } } ``` -------------------------------- ### Get Platform Language in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves the current language code from the platform, allowing for game localization. The function returns a string like 'en', 'ru', or 'de'. ```gml // Get user's language preference from the platform var language = playgama_bridge_platform_language(); show_debug_message("User language: " + language); // Set game localization based on platform language switch (language) { case "ru": global.strings = load_strings_russian(); break; case "de": global.strings = load_strings_german(); break; default: global.strings = load_strings_english(); break; } ``` -------------------------------- ### Manage Favorites and Home Screen Shortcuts Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Provides methods to check support and trigger adding the game to favorites or the device home screen. ```gml var favorites_supported = playgama_bridge_social_is_add_to_favorites_supported(); if (favorites_supported == "1") { playgama_bridge_social_add_to_favorites(); } var home_screen_supported = playgama_bridge_social_is_add_to_home_screen_supported(); if (home_screen_supported == "1") { playgama_bridge_social_add_to_home_screen(); } ``` -------------------------------- ### Configuration File Source: https://context7.com/playgama/bridge-gamemaker/llms.txt The playgama-bridge-config.json file defines platform-specific behaviors and SDK settings. ```APIDOC ## playgama-bridge-config.json ### Description Configuration file located in the datafiles folder that controls platform-specific settings, advertisement behavior, and analytics. ### Structure - **device** (object) - Orientation and UI settings. - **platforms** (object) - Platform-specific IDs and flags (e.g., Telegram, Yandex, CrazyGames). - **advertisement** (object) - Ad preloading and error handling settings. ### Configuration Example { "platforms": { "telegram": { "adsgramBlockId": "your-adsgram-block-id" } }, "advertisement": { "interstitial": { "preloadOnStart": true } } } ``` -------------------------------- ### Initialize Playgama Bridge with GameMaker Source: https://github.com/playgama/bridge-gamemaker/blob/main/datafiles/playgama-bridge-index.html This JavaScript code snippet handles the loading and initialization of the Playgama Bridge for GameMaker HTML5 projects. It attempts to load the bridge from a CDN and falls back to a local script if the CDN fails or times out. It also configures the bridge with the engine type and initialization settings. ```javascript let bridgeScript = null let bridgeTimeout = null let bridgeLoaded = false function addLocalBridge() { if (bridgeLoaded) return bridgeLoaded = true clearTimeout(bridgeTimeout) if (bridgeScript && bridgeScript.parentNode) { bridgeScript.onload = null bridgeScript.onerror = null bridgeScript.src = '' bridgeScript.parentNode.removeChild(bridgeScript) } const scriptElement = document.createElement('script') scriptElement.src = './html5game/playgama-bridge.js' document.body.appendChild(scriptElement) scriptElement.onload = function() { initializeBridge() } } bridgeScript = document.createElement('script') bridgeScript.src = 'https://bridge.playgama.com/v1/stable/playgama-bridge.js' bridgeScript.onload = initializeBridge bridgeScript.onerror = addLocalBridge bridgeTimeout = setTimeout(() => { console.warn('CDN bridge failed to load within 2 seconds, loading local bridge') addLocalBridge() }, 2000) document.head.appendChild(bridgeScript) function initializeBridge() { clearTimeout(bridgeTimeout) bridge.engine = 'gamemaker' bridge.initialize({ configFilePath: './html5game/playgama-bridge-config.json' }) .then(() => { GameMaker_Init() }) } ``` -------------------------------- ### Check Storage Availability Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Verifies if specific storage types are supported or available on the current platform and retrieves the default storage type. ```gml // Check if platform internal storage is supported var is_supported = playgama_bridge_storage_is_supported("platform_internal"); show_debug_message("Platform storage supported: " + is_supported); // Check if local storage is available var is_available = playgama_bridge_storage_is_available("local_storage"); show_debug_message("Local storage available: " + is_available); // Get default storage type for current platform var default_type = playgama_bridge_storage_default_type(); show_debug_message("Default storage type: " + default_type); ``` -------------------------------- ### Device and Visibility API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Functions to detect the current device type and monitor the game window's visibility state. ```APIDOC ## GET playgama_bridge_device_type() ### Description Returns the type of device the game is currently running on (e.g., mobile, tablet, desktop, tv). ### Method Function Call ### Response - **Returns** (string) - The device category identifier. ## GET playgama_bridge_game_visibility_state() ### Description Returns the current visibility state of the game window, useful for pausing or resuming game logic. ### Method Function Call ### Response - **Returns** (string) - 'visible' or 'hidden'. ``` -------------------------------- ### Purchase Product (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Initiates a purchase transaction for a specific product ID using `playgama_bridge_payments_purchase()`. The callback handles success by granting the item or failure. ```gml // Purchase a product var product_id = "coins_pack_1000"; var options = json_stringify({}); playgama_bridge_payments_purchase(product_id, options); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_payments_purchase_callback") { if (async_load[? "success"]) { var purchase = json_parse(async_load[? "data"]); var product_id = purchase.id; // Grant purchased item switch (product_id) { case "coins_pack_1000": global.coins += 1000; break; case "remove_ads": global.ads_removed = true; break; } show_debug_message("Purchase successful: " + product_id); } else { show_debug_message("Purchase failed or cancelled"); } } ``` -------------------------------- ### Retrieve Remote Config Values Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Fetches remote configuration data and applies it to global game variables upon successful callback. ```gml var config_supported = playgama_bridge_remote_config_is_supported(); if (config_supported == "1") { var options = json_stringify({}); playgama_bridge_remote_config_get(options); } if (async_load[? "type"] == "playgama_bridge_remote_config_get_callback") { if (async_load[? "success"]) { var values = json_parse(async_load[? "data"]); if (variable_struct_exists(values, "daily_reward_amount")) { global.daily_reward = values.daily_reward_amount; } if (variable_struct_exists(values, "special_offer_enabled")) { global.show_special_offer = values.special_offer_enabled; } } } ``` -------------------------------- ### Check External Links Availability Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Determines if the current platform allows external links, useful for toggling visibility of 'More Games' buttons. ```gml var links_allowed = playgama_bridge_social_is_external_links_allowed(); if (links_allowed == "1") { obj_more_games_button.visible = true; } ``` -------------------------------- ### Remote Config API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves remote configuration values to dynamically adjust game parameters without requiring a new build. ```APIDOC ## GET Remote Config ### Description Fetches remote configuration data from the platform and applies it to the game state. ### Method N/A (GML Function calls) ### Response #### Success Response (Async Event) - **type** (string) - "playgama_bridge_remote_config_get_callback" - **data** (string) - JSON string containing the remote configuration key-value pairs. ### Response Example { "daily_reward_amount": 100, "special_offer_enabled": true } ``` -------------------------------- ### Player Authorization and Profile Management Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Handles checking authorization support, requesting player login, and retrieving profile details like ID, name, and photos. ```gml // Check if authorization is supported var auth_supported = playgama_bridge_player_is_authorization_supported(); if (auth_supported == "1") { obj_login_button.visible = true; } // Request player authorization var options = json_stringify({ scopes: false }); playgama_bridge_player_authorize(options); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_player_authorize_callback") { if (async_load[? "success"]) { show_debug_message("Player authorized successfully!"); var player_id = playgama_bridge_player_id(); var player_name = playgama_bridge_player_name(); } else { show_debug_message("Authorization failed or cancelled"); } } // Get player information var is_authorized = playgama_bridge_player_is_authorized(); if (is_authorized == "1") { var player_id = playgama_bridge_player_id(); var player_name = playgama_bridge_player_name(); var player_photos = playgama_bridge_player_photos(); if (player_photos != "null") { var photos = json_parse(player_photos); if (array_length(photos) > 0) { global.avatar_url = photos[0]; } } } ``` -------------------------------- ### Manage Game Visibility State Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Monitors the game window visibility state to pause or resume game logic, such as audio and frame rate, when the app is hidden or visible. ```gml var visibility_state = playgama_bridge_game_visibility_state(); if (async_load[? "type"] == "playgama_bridge_game_visibility_state_changed") { switch (async_load[? "data"]) { case "visible": audio_resume_all(); game_set_speed(60, gamespeed_fps); break; case "hidden": audio_pause_all(); game_set_speed(0, gamespeed_fps); break; } } ``` -------------------------------- ### Rate Game Functionality Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Prompts the user to rate the game after verifying platform support. Callback handling is performed in the Social Async event. ```gml var rate_supported = playgama_bridge_social_is_rate_supported(); if (rate_supported == "1") { playgama_bridge_social_rate(); } if (async_load[? "type"] == "playgama_bridge_social_rate_callback") { if (async_load[? "success"]) { show_debug_message("Thanks for rating!"); } } ``` -------------------------------- ### Show Native Achievements Popup (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Displays the platform's native achievements UI. It takes JSON stringified options and handles the callback in the Social Async event to confirm closure. ```gml // Show native achievements popup var options = json_stringify({}); playgama_bridge_achievements_show_native_popup(options); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_achievements_show_native_popup_callback") { if (async_load[? "success"]) { show_debug_message("Native achievements popup closed"); } } ``` -------------------------------- ### Manage Achievements Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Provides methods to check platform support for achievements, unlock specific achievements, and retrieve the full list of available achievements. ```gml var supported = playgama_bridge_achievements_is_supported(); var options = json_stringify({ id: "first_victory" }); playgama_bridge_achievements_unlock(options); playgama_bridge_achievements_get_list(json_stringify({})); ``` -------------------------------- ### Check Audio State in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Checks if audio is currently enabled by the platform. This is useful for platforms that might mute games by default, allowing manual control over audio. ```gml // Check if audio is enabled var audio_enabled = playgama_bridge_platform_is_audio_enabled(); if (audio_enabled == "1") { audio_master_gain(1); } else { audio_master_gain(0); } ``` -------------------------------- ### Banner Advertisements Management Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Enables the display and management of banner advertisements at specified screen positions ('top' or 'bottom'). The code demonstrates how to check for banner support, show banners with placement identifiers, hide banners, and handle banner state changes. ```gml // Check if banners are supported var banners_supported = playgama_bridge_advertisement_is_banner_supported(); if (banners_supported == "1") { // Show banner at bottom of screen playgama_bridge_advertisement_show_banner("bottom", "main_menu"); // Alternative positions: "top", "bottom" playgama_bridge_advertisement_show_banner("top", "gameplay"); } // Hide the banner playgama_bridge_advertisement_hide_banner(); // Handle banner state changes in Social Async event if (async_load[? "type"] == "playgama_bridge_advertisement_banner_state_changed") { switch (async_load[? "data"]) { case "loading": show_debug_message("Banner loading..."); break; case "shown": show_debug_message("Banner visible"); break; case "hidden": show_debug_message("Banner hidden"); break; case "failed": show_debug_message("Banner failed to load"); break; } } ``` -------------------------------- ### Platform Information API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Provides functions to retrieve information about the current gaming platform and user preferences. ```APIDOC ## Get Platform ID ### Description Returns the identifier of the current platform where the game is running (e.g., "playgama", "yandex", "crazy_games", "telegram"). ### Method `playgama_bridge_platform_id()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml var platform_id = playgama_bridge_platform_id(); show_debug_message("Running on platform: " + platform_id); ``` ### Response - **platform_id** (string) - The identifier of the current platform. ### Response Example ``` "yandex" ``` ## Get Platform Language ### Description Returns the current language code from the platform (e.g., "en", "ru", "de"). ### Method `playgama_bridge_platform_language()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml var language = playgama_bridge_platform_language(); show_debug_message("User language: " + language); ``` ### Response - **language** (string) - The language code of the current platform. ### Response Example ``` "en" ``` ## Get Platform Payload ### Description Returns any payload data passed to the game via URL parameters or platform-specific deep linking. ### Method `playgama_bridge_platform_payload()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml var payload = playgama_bridge_platform_payload(); if (payload != "null" && payload != "") { var payload_data = json_parse(payload); if (variable_struct_exists(payload_data, "invite_code")) { global.invite_code = payload_data.invite_code; } } ``` ### Response - **payload** (string) - The payload data as a JSON string, or "null"/empty string if no payload. ### Response Example ``` "{\"invite_code\": \"12345\"}" ``` ## Send Platform Message ### Description Sends a message to the platform, commonly used to indicate game state changes like "game_ready". ### Method `playgama_bridge_platform_send_message(message_name, message_data)` ### Endpoint N/A (GML function) ### Parameters - **message_name** (string) - Required - The name of the message to send (e.g., "game_ready"). - **message_data** (string) - Required - JSON string representing the message data. ### Request Example ```gml playgama_bridge_platform_send_message("game_ready", "{}"); playgama_bridge_platform_send_message("gameplay_start", "{}"); playgama_bridge_platform_send_message("gameplay_stop", "{}"); ``` ### Response None ## Get Server Time ### Description Retrieves the current server time from the platform. Result is received asynchronously. ### Method `playgama_bridge_platform_get_server_time()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml playgama_bridge_platform_get_server_time(); // Handle callback in Social Async event (Other_70.gml) if (async_load[? "type"] == "playgama_bridge_platform_get_server_time_callback") { if (async_load[? "success"]) { var server_time = async_load[? "data"]; show_debug_message("Server time: " + string(server_time)); } } ``` ### Response - **data** (number) - The server time (timestamp) if successful. - **success** (boolean) - Indicates if the request was successful. ### Response Example ``` { "type": "playgama_bridge_platform_get_server_time_callback", "success": true, "data": 1678886400 } ``` ## Check Audio State ### Description Returns whether audio is currently enabled by the platform. Useful for platforms that may mute games by default. ### Method `playgama_bridge_platform_is_audio_enabled()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml var audio_enabled = playgama_bridge_platform_is_audio_enabled(); if (audio_enabled == "1") { audio_master_gain(1); } else { audio_master_gain(0); } ``` ### Response - **audio_enabled** (string) - "1" if audio is enabled, "0" otherwise. ### Response Example ``` "1" ``` ## Check Pause State ### Description Returns whether the game is currently paused by the platform. ### Method `playgama_bridge_platform_is_paused()` ### Endpoint N/A (GML function) ### Parameters None ### Request Example ```gml var is_paused = playgama_bridge_platform_is_paused(); if (is_paused == "1") { game_pause(); } ``` ### Response - **is_paused** (string) - "1" if the game is paused, "0" otherwise. ### Response Example ``` "1" ``` ``` -------------------------------- ### Join Community via Playgama Bridge Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Checks if community joining is supported on the current platform and triggers the join action. Results are handled within the Social Async event. ```gml var join_supported = playgama_bridge_social_is_join_community_supported(); if (join_supported == "1") { var options = json_stringify({}); playgama_bridge_social_join_community(options); } if (async_load[? "type"] == "playgama_bridge_social_join_community_callback") { if (async_load[? "success"]) { show_debug_message("Joined community!"); } } ``` -------------------------------- ### Storage Management API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Endpoints for managing persistent key-value data storage across different platform types. ```APIDOC ## POST /storage/set ### Description Saves key-value data to persistent storage. Supports complex objects by serializing them to JSON strings. ### Method POST ### Parameters #### Request Body - **key** (string) - Required - The key identifier for the data. - **value** (string) - Required - The data to store (JSON string). - **storage_type** (string) - Required - The storage backend (e.g., "platform_internal"). ### Request Example playgama_bridge_storage_set(json_stringify("key"), json_stringify("value"), "platform_internal"); ### Response #### Success Response (200) - **async_load** (map) - Contains "success" boolean and "type" set to "playgama_bridge_storage_set_callback". ``` -------------------------------- ### Invite Friends (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Invites friends to play the game using `playgama_bridge_social_invite_friends()`. It checks for support first with `playgama_bridge_social_is_invite_friends_supported()` and allows custom invitation text. ```gml // Check if inviting friends is supported var invite_supported = playgama_bridge_social_is_invite_friends_supported(); if (invite_supported == "1") { var options = json_stringify({ text: "Join me in this awesome game!" }); playgama_bridge_social_invite_friends(options); } // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_social_invite_friends_callback") { if (async_load[? "success"]) { show_debug_message("Invitation sent!"); } } ``` -------------------------------- ### Set Minimum Delay Between Interstitials Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Configures the minimum time in seconds between interstitial ad displays to prevent excessive ad frequency. Includes functions to set the delay and retrieve the current setting. ```gml // Set minimum 60 seconds between interstitial ads playgama_bridge_advertisement_set_minimum_delay_between_interstitial(60); // Get current minimum delay setting var current_delay = playgama_bridge_advertisement_minimum_delay_between_interstitial(); show_debug_message("Current delay: " + string(current_delay) + " seconds"); ``` -------------------------------- ### Player Authentication API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Endpoints for handling player authorization and retrieving profile information. ```APIDOC ## POST /player/authorize ### Description Prompts the user to authorize or login through the platform's native authentication system. ### Method POST ### Parameters #### Request Body - **options** (string) - Required - JSON string containing authorization scopes. ### Request Example playgama_bridge_player_authorize(json_stringify({ "scopes": false })); ### Response #### Success Response (200) - **async_load** (map) - Contains "success" boolean and "type" set to "playgama_bridge_player_authorize_callback". ``` -------------------------------- ### Load Data from Persistent Storage Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves data associated with a key from storage. The result is returned via the 'playgama_bridge_storage_get_callback' event, where the data must be parsed from JSON. ```gml // Load single value var key = json_stringify("player_score"); playgama_bridge_storage_get(key, "platform_internal"); // Load complex object var key = json_stringify("game_progress"); playgama_bridge_storage_get(key, "platform_internal"); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_storage_get_callback") { if (async_load[? "success"]) { var data = json_parse(async_load[? "data"]); global.level = data.level; global.coins = data.coins; global.upgrades = data.upgrades; show_debug_message("Data loaded: Level " + string(global.level)); } else { show_debug_message("No saved data found"); } } ``` -------------------------------- ### Check Payments Support (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Determines if in-app purchases are supported on the current platform using `playgama_bridge_payments_is_supported()`. If supported, it makes a shop button visible. ```gml // Check if payments are supported var payments_supported = playgama_bridge_payments_is_supported(); if (payments_supported == "1") { // Show shop button obj_shop_button.visible = true; } ``` -------------------------------- ### Detect Device Type in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Retrieves the current device type (mobile, tablet, desktop, or tv) to allow for conditional game logic, such as enabling touch controls or adjusting UI scale. ```gml var device_type = playgama_bridge_device_type(); show_debug_message("Device type: " + device_type); switch (device_type) { case "mobile": global.use_touch_controls = true; break; case "tablet": global.use_touch_controls = true; global.ui_scale = 1.2; break; case "desktop": global.use_touch_controls = false; break; case "tv": global.use_gamepad = true; break; } ``` -------------------------------- ### Share Game (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Allows players to share the game on social platforms. It first checks support with `playgama_bridge_social_is_share_supported()` and then uses `playgama_bridge_social_share()` with optional text. ```gml // Check if sharing is supported var share_supported = playgama_bridge_social_is_share_supported(); if (share_supported == "1") { // Share with options var options = json_stringify({ text: "Check out my high score of " + string(global.high_score) + "!" }); playgama_bridge_social_share(options); } // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_social_share_callback") { if (async_load[? "success"]) { show_debug_message("Shared successfully!"); } } ``` -------------------------------- ### Submit and Retrieve Leaderboard Data Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Functions to submit player scores to a leaderboard and retrieve entries for display, handling results via the Social Async event. ```gml playgama_bridge_leaderboards_set_score("high_scores", 15000); var options = json_stringify({ id: "high_scores", limit: 10, includeUser: true }); playgama_bridge_leaderboards_get_entries(options); if (async_load[? "type"] == "playgama_bridge_leaderboards_get_entries_callback") { if (async_load[? "success"]) { var entries = json_parse(async_load[? "data"]); for (var i = 0; i < array_length(entries); i++) { show_debug_message(entries[i].name + ": " + string(entries[i].score)); } } } ``` -------------------------------- ### Social Module API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt APIs for social interactions, including sharing game content and inviting friends. ```APIDOC ## Share Game ### Description Allows players to share game-related content on social platforms. ### Method POST ### Endpoint `/playgama/bridge/social/share` ### Parameters #### Request Body - **options** (string) - Required - JSON string containing sharing options, such as `text`. ### Request Example ```json { "options": "{\"text\": \"Check out my high score of 1000!\"}" } ``` ### Response #### Success Response (200) Indicates the share action was initiated successfully. #### Response Example ```json { "success": true } ``` ### Callback Event - **type**: `playgama_bridge_social_share_callback` - **success**: (boolean) - True if the sharing action was successful. ``` ```APIDOC ## Invite Friends ### Description Invites friends to play the game through available social channels. ### Method POST ### Endpoint `/playgama/bridge/social/invite_friends` ### Parameters #### Request Body - **options** (string) - Required - JSON string containing invitation options, such as `text`. ### Request Example ```json { "options": "{\"text\": \"Join me in this awesome game!\"}" } ``` ### Response #### Success Response (200) Indicates the friend invitation was initiated successfully. #### Response Example ```json { "success": true } ``` ### Callback Event - **type**: `playgama_bridge_social_invite_friends_callback` - **success**: (boolean) - True if the invitation was sent successfully. ``` -------------------------------- ### Consume Purchase (GML) Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Consumes a consumable purchase using `playgama_bridge_payments_consume_purchase()`, which is necessary for some platforms to allow re-purchasing. Handles success callback. ```gml // Consume a purchase after granting reward var product_id = "coins_pack_1000"; playgama_bridge_payments_consume_purchase(product_id); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_payments_consume_purchase_callback") { if (async_load[? "success"]) { show_debug_message("Purchase consumed successfully"); } } ``` -------------------------------- ### Payments Module API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt APIs for managing in-app purchases, including checking support, retrieving product catalogs, purchasing items, consuming purchases, and restoring player purchases. ```APIDOC ## Check Payments Support ### Description Determines if in-app purchases are supported on the current platform. ### Method GET ### Endpoint `/playgama/bridge/payments/is_supported` ### Response #### Success Response (200) - **supported** (string) - Returns "1" if payments are supported, otherwise "0". ### Response Example ```json { "supported": "1" } ``` ``` ```APIDOC ## Get Product Catalog ### Description Retrieves the list of available products/items for purchase. ### Method GET ### Endpoint `/playgama/bridge/payments/get_catalog` ### Response #### Success Response (200) - **catalog** (array) - An array of product objects. - **id** (string) - The product identifier. - **price** (string) - The formatted price of the product. - **currency** (string) - The currency code (e.g., "USD"). - **price_value** (number) - The price as a numerical value. ### Response Example ```json { "catalog": [ { "id": "coins_pack_1000", "price": "$9.99", "currency": "USD", "price_value": 9.99 } ] } ``` ### Callback Event - **type**: `playgama_bridge_payments_get_catalog_callback` - **success**: (boolean) - True if the catalog was retrieved successfully. - **data**: (string) - JSON string of the product catalog. ``` ```APIDOC ## Purchase Product ### Description Initiates a purchase transaction for a specific product. ### Method POST ### Endpoint `/playgama/bridge/payments/purchase` ### Parameters #### Request Body - **product_id** (string) - Required - The identifier of the product to purchase. - **options** (string) - Optional - JSON string of options for the purchase. ### Request Example ```json { "product_id": "coins_pack_1000", "options": "{}" } ``` ### Response #### Success Response (200) - **purchase** (object) - Details of the purchase. - **id** (string) - The product identifier. #### Response Example ```json { "purchase": { "id": "coins_pack_1000" } } ``` ### Callback Event - **type**: `playgama_bridge_payments_purchase_callback` - **success**: (boolean) - True if the purchase was successful. - **data**: (string) - JSON string of the purchase details if successful. ``` ```APIDOC ## Consume Purchase ### Description Consumes a consumable purchase, typically after granting the reward to the user. This is required for some platforms to allow re-purchasing. ### Method POST ### Endpoint `/playgama/bridge/payments/consume_purchase` ### Parameters #### Request Body - **product_id** (string) - Required - The identifier of the product to consume. ### Request Example ```json { "product_id": "coins_pack_1000" } ``` ### Response #### Success Response (200) Indicates the purchase was consumed successfully. #### Response Example ```json { "success": true } ``` ### Callback Event - **type**: `playgama_bridge_payments_consume_purchase_callback` - **success**: (boolean) - True if the purchase was consumed successfully. ``` ```APIDOC ## Get Player Purchases ### Description Retrieves a list of purchases made by the current player, often used for restoring purchases. ### Method GET ### Endpoint `/playgama/bridge/payments/get_purchases` ### Response #### Success Response (200) - **purchases** (array) - An array of purchased product objects. - **id** (string) - The product identifier. ### Response Example ```json { "purchases": [ { "id": "remove_ads" } ] } ``` ### Callback Event - **type**: `playgama_bridge_payments_get_purchases_callback` - **success**: (boolean) - True if the purchases were retrieved successfully. - **data**: (string) - JSON string of the player's purchases. ``` -------------------------------- ### Check Ad Blocker Status Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Detects whether the user has an ad blocker enabled. The result is returned via an asynchronous callback in the Social Async event, indicating success and whether an ad blocker was detected. ```gml // Check for ad blocker playgama_bridge_advertisement_check_adblock(); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_advertisement_check_adblock_callback") { if (async_load[? "success"]) { var is_adblock_detected = async_load[? "data"]; if (is_adblock_detected == "1" || is_adblock_detected == "true") { show_message("Please disable ad blocker to support the game!"); } } } ``` -------------------------------- ### Achievements API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Provides functionality to interact with the platform's native achievements UI. ```APIDOC ## Show Native Achievements Popup ### Description Displays the platform's native achievements UI. ### Method POST (or equivalent function call) ### Endpoint `/playgama/bridge/achievements/show_native_popup` ### Parameters #### Request Body - **options** (string) - Optional - JSON string of options for the popup. ### Request Example ```json { "options": "{}" } ``` ### Response #### Success Response (200) Indicates the popup was displayed or closed. #### Response Example ```json { "success": true } ``` ### Callback Event - **type**: `playgama_bridge_achievements_show_native_popup_callback` - **success**: (boolean) - True if the popup was handled successfully. ``` -------------------------------- ### Leaderboards API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Functions for submitting scores, retrieving leaderboard entries, and displaying native platform leaderboards. ```APIDOC ## POST playgama_bridge_leaderboards_set_score ### Description Submits a player's score to a specific leaderboard. ### Parameters - **leaderboard_id** (string) - Required - **player_score** (number) - Required ## GET playgama_bridge_leaderboards_get_entries ### Description Retrieves a list of leaderboard entries. ### Parameters - **options** (json string) - Required: {id: string, limit: number, includeUser: boolean} ## POST playgama_bridge_leaderboards_show_native_popup ### Description Displays the platform's native leaderboard UI. ### Parameters - **options** (json string) - Required: {id: string} ``` -------------------------------- ### Show Interstitial Ad Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Displays a full-screen interstitial advertisement. Results are received through asynchronous callbacks. It's recommended to check ad support before attempting to show an ad and handle state changes in the Social Async event. ```gml // Show interstitial ad with optional placement identifier playgama_bridge_advertisement_show_interstitial("level_complete"); // Check ad support before showing var is_supported = playgama_bridge_advertisement_is_interstitial_supported(); if (is_supported == "1") { playgama_bridge_advertisement_show_interstitial("between_levels"); } // Handle state changes in Social Async event (Other_70.gml) if (async_load[? "type"] == "playgama_bridge_advertisement_interstitial_state_changed") { switch (async_load[? "data"]) { case "loading": show_debug_message("Interstitial loading..."); break; case "opened": audio_master_gain(0); // Mute game audio game_set_speed(0, gamespeed_fps); // Pause game break; case "closed": audio_master_gain(1); // Restore audio game_set_speed(60, gamespeed_fps); // Resume game break; case "failed": show_debug_message("Interstitial failed to load"); break; } } ``` -------------------------------- ### Achievements API Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Functions for checking platform support, unlocking achievements, and listing available achievements. ```APIDOC ## GET playgama_bridge_achievements_is_supported ### Description Checks if achievements are supported on the current platform. ## POST playgama_bridge_achievements_unlock ### Description Unlocks a specific achievement. ### Parameters - **options** (json string) - Required: {id: string} ## GET playgama_bridge_achievements_get_list ### Description Retrieves the full list of achievements and their status. ``` -------------------------------- ### Check Pause State in GameMaker Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Determines if the game is currently paused by the platform. This function returns '1' if paused and '0' otherwise. ```gml // Check if game is paused var is_paused = playgama_bridge_platform_is_paused(); if (is_paused == "1") { game_pause(); } ``` -------------------------------- ### Basic HTML5 Canvas and Body Styles Source: https://github.com/playgama/bridge-gamemaker/blob/main/datafiles/playgama-bridge-index.html These CSS rules define basic styling for the HTML5 canvas element and the page body within a GameMaker HTML5 export. They ensure proper rendering, prevent default browser behaviors like image scaling, and set background and text colors. ```css body { background: ${GM_HTML5_BackgroundColour}; color: #cccccc; margin: 0px; padding: 0px; border: 0px; } canvas { image-rendering: optimizeSpeed; -webkit-interpolation-mode: nearest-neighbor; -ms-touch-action: none; touch-action: none; margin: 0px; padding: 0px; border: 0px; } :-webkit-full-screen #canvas { width: 100%; height: 100%; } :-webkit-full-screen { width: 100%; height: 100%; } ``` -------------------------------- ### Save Data to Persistent Storage Source: https://context7.com/playgama/bridge-gamemaker/llms.txt Saves key-value pairs or complex objects to platform-specific storage. It requires handling the 'playgama_bridge_storage_set_callback' in the Social Async event to confirm success. ```gml // Save single value var key = json_stringify("player_score"); var value = json_stringify(12500); playgama_bridge_storage_set(key, value, "platform_internal"); // Save complex object var save_data = { level: 5, coins: 1000, upgrades: ["speed", "armor"] }; var key = json_stringify("game_progress"); var value = json_stringify(save_data); playgama_bridge_storage_set(key, value, "platform_internal"); // Handle callback in Social Async event if (async_load[? "type"] == "playgama_bridge_storage_set_callback") { if (async_load[? "success"]) { show_debug_message("Data saved successfully!"); } else { show_debug_message("Failed to save data"); } } ``` -------------------------------- ### Custom Runner Styles for Playgama Bridge Source: https://github.com/playgama/bridge-gamemaker/blob/main/datafiles/playgama-bridge-index.html This CSS block provides custom styles for elements related to the Playgama Bridge runner, such as login forms and buttons. It includes styles for the main container, login box, cancel button, login button, and header, allowing for a customized user interface. ```css div.gm4html5_div_class { margin: 0px; padding: 0px; border: 0px; } div.gm4html5_login { padding: 20px; position: absolute; border: solid 2px #000000; background-color: #404040; color:#00ff00; border-radius: 15px; box-shadow: #101010 20px 20px 40px; } div.gm4html5_cancel_button { float: right; } div.gm4html5_login_button { float: left; } div.gm4html5_login_header { text-align: center; } ```