### Full Physics Setup (BASIC) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.htm Combines all previous steps: setting resolution, loading background, creating and positioning sprites, and enabling dynamic physics for them. Includes the main loop. ```basic SetVirtualResolution ( 320, 480 ) CreateSprite ( LoadImage ( "background3.jpg" ) ) LoadImage ( 1, "small_ball.png" ) CreateSprite ( 1, 1 ) CreateSprite ( 2, 1 ) CreateSprite ( 3, 1 ) CreateSprite ( 4, 1 ) CreateSprite ( 5, 1 ) SetSpritePosition ( 1, 0, 0 ) SetSpritePosition ( 2, 60, 0 ) SetSpritePosition ( 3, 120, 0 ) SetSpritePosition ( 4, 180, 0 ) SetSpritePosition ( 5, 240, 0 ) SetSpritePhysicsOn ( 1, 2 ) SetSpritePhysicsOn ( 2, 2 ) SetSpritePhysicsOn ( 3, 2 ) SetSpritePhysicsOn ( 4, 2 ) SetSpritePhysicsOn ( 5, 2 ) do Sync ( ) loop ``` -------------------------------- ### Full Code Listing (AppGameKit C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.txt A complete AppGameKit C++ code example demonstrating setup, sprite creation, physics enablement, and the main loop structure. ```cpp void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 );
agk::CreateSprite ( agk::LoadImage ( "background3.jpg" ) );
agk::LoadImage ( 1, "small_ball.png" );
agk::CreateSprite ( 1, 1 ); agk::CreateSprite ( 2, 1 ); agk::CreateSprite ( 3, 1 ); agk::CreateSprite ( 4, 1 ); agk::CreateSprite ( 5, 1 );
agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpritePosition ( 2, 60, 0 ); agk::SetSpritePosition ( 3, 120, 0 ); agk::SetSpritePosition ( 4, 180, 0 ); agk::SetSpritePosition ( 5, 240, 0 ); }
void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Full Physics Setup (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.htm A complete C++ implementation for AGK, including initialization of the virtual resolution, loading a background, creating and positioning sprites, enabling dynamic physics, and the main loop structure. ```cpp void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::CreateSprite ( agk::LoadImage ( "background3.jpg" ) ); agk::LoadImage ( 1, "small_ball.png" ); agk::CreateSprite ( 1, 1 ); agk::CreateSprite ( 2, 1 ); agk::CreateSprite ( 3, 1 ); agk::CreateSprite ( 4, 1 ); agk::CreateSprite ( 5, 1 ); agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpritePosition ( 2, 60, 0 ); agk::SetSpritePosition ( 3, 120, 0 ); agk::SetSpritePosition ( 4, 180, 0 ); agk::SetSpritePosition ( 5, 240, 0 ); } void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Full Code Listing (AppGameKit Classic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.txt A complete AppGameKit Classic code example including setting resolution, loading background, creating and positioning sprites, enabling physics, and the main loop. ```appgamekit SetVirtualResolution ( 320, 480 )
CreateSprite ( LoadImage ( "background3.jpg" ) )
LoadImage ( 1, "small_ball.png" )
CreateSprite ( 1, 1 ) CreateSprite ( 2, 1 ) CreateSprite ( 3, 1 ) CreateSprite ( 4, 1 ) CreateSprite ( 5, 1 )
SetSpritePosition ( 1, 0, 0 ) SetSpritePosition ( 2, 60, 0 ) SetSpritePosition ( 3, 120, 0 ) SetSpritePosition ( 4, 180, 0 ) SetSpritePosition ( 5, 240, 0 )
SetSpritePhysicsOn ( 1, 2 ) SetSpritePhysicsOn ( 2, 2 ) SetSpritePhysicsOn ( 3, 2 ) SetSpritePhysicsOn ( 4, 2 ) SetSpritePhysicsOn ( 5, 2 )
do Sync ( ) loop ``` -------------------------------- ### App Game Kit: Full Program Setup and Emitter Creation Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/particles/1_emitter.htm This comprehensive code listing includes the full setup for an App Game Kit application, starting with setting the virtual resolution and creating a background sprite. It then proceeds to create and configure the particle emitter, similar to the previous snippet, and includes the main loop for execution. This is the complete code for the example program. ```AGK BASIC SetVirtualResolution ( 320, 480 ) CreateSprite ( LoadImage ( "alien_backdrop.jpg" ) ) LoadImage ( 1, "test2.png" ) CreateParticles ( 1, 150, 250 ) SetParticlesImage ( 1, 1 ) SetParticlesStartZone ( 1, -5, 0, 5, 0 ) SetParticlesDirection ( 1, 0, -145 ) SetParticlesAngle ( 1, 15 ) SetParticlesFrequency ( 1, 60 ) SetParticlesLife ( 1, 1.5 ) SetParticlesSize ( 1, 16 ) AddParticlesColorKeyFrame ( 1, 0, 255, 255, 255, 255 ) AddParticlesColorKeyFrame ( 1, 1.5, 255, 255, 255, 0 ) do Sync ( ) loop ``` ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::CreateSprite ( agk::LoadImage ( "alien_backdrop.jpg" ) ); agk::LoadImage ( 1, "test2.png" ); agk::CreateParticles ( 1, 150, 250 ); agk::SetParticlesImage ( 1, 1 ); agk::SetParticlesStartZone ( 1, -5, 0, 5, 0 ); agk::SetParticlesDirection ( 1, 0, -145.0f ); agk::SetParticlesAngle ( 1, 15 ); agk::SetParticlesFrequency ( 1, 60 ); agk::SetParticlesLife ( 1, 1.5 ); agk::SetParticlesSize ( 1, 16 ); agk::AddParticlesColorKeyFrame ( 1, 0, 255, 255, 255, 255 ); agk::AddParticlesColorKeyFrame ( 1, 1.5, 255, 255, 255, 0 ); } void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Full Particle System Setup Example Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/particles/0_creating.txt Demonstrates a comprehensive setup for a particle system, including setting resolution, loading images, creating particles, and configuring their behavior and appearance. ```tier1 SetVirtualResolution ( 320, 480 ) backdrop = CreateSprite ( LoadImage ( "background1.jpg" ) ) LoadImage ( 1, "particle.png" ) CreateParticles ( 1, 150, 10 ) SetParticlesImage ( 1, 1 ) SetParticlesStartZone ( 1, -100, -10, 100, 10 ) SetParticlesDirection ( 1, 0, 50.0 ) SetParticlesLife ( 1, 9 ) SetParticlesSize ( 1, 24 ) SetParticlesAngle ( 1, 15 ) SetParticlesFrequency ( 1, 60 ) SetParticlesVelocityRange ( 1, 1, 4 ) AddParticlesColorKeyFrame ( 1, 0, 0, 100, 255, 0 ) AddParticlesColorKeyFrame ( 1, 0.5, 0, 100, 255, 255 ) AddParticlesColorKeyFrame ( 1, 2.0, 150, 50, 100, 255 ) AddParticlesColorKeyFrame ( 1, 9.0, 0, 0, 0, 0 ) do Sync ( ) loop ``` -------------------------------- ### Create and Position Sprites (AppGameKit Classic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.txt Loads an image and creates five sprites, then positions them horizontally across the screen. This is the initial setup before enabling physics. ```appgamekit LoadImage ( 1, "small_ball.png" )
CreateSprite ( 1, 1 ) CreateSprite ( 2, 1 ) CreateSprite ( 3, 1 ) CreateSprite ( 4, 1 ) CreateSprite ( 5, 1 )
SetSpritePosition ( 1, 0, 0 ) SetSpritePosition ( 2, 60, 0 ) SetSpritePosition ( 3, 120, 0 ) SetSpritePosition ( 4, 180, 0 ) SetSpritePosition ( 5, 240, 0 ) ``` -------------------------------- ### Game State Initialization and Network Setup (AGK) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Initializes game state variables such as State, Typ, and NetworkID. It then enters a loop to handle game initialization, allowing players to host or join a network game based on sprite interaction. ```AGK State = 0 Typ = 0 NetworkID = 0 do if State = 0 Print ( "Select yellow chip to host a game" ) Print ( "Select blue chip to join a game" ) if GetPointerPressed ( ) = 1 hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) ) if ( hit = 1 ) NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 48230 ) Typ = 0 endif if ( hit = 2 ) NetworkID = JoinNetwork ( "AGK Test Game", "Player 2" ) Typ = 1 endif State = 1 endif endif if State = 1 and IsNetworkActive ( NetworkID ) <> 0 id = GetNetworkFirstClient ( NetworkID ) while id <> 0 Print ( GetNetworkClientName ( NetworkID, id ) ) id = GetNetworkNextClient ( NetworkID ) endwhile // ... rest of the game loop ... ``` -------------------------------- ### Initialize Game Environment (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/input/0_getting_started.htm This C++ code sets up the virtual resolution for the game and loads/creates two sprites: a background image and a movable sprite. The Begin function is typically called once at the start of the application. ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::CreateSprite ( agk::LoadImage ( "background5.jpg" ) ); agk::CreateSprite ( 1, agk::LoadImage ( "lime.png" ) ); } ``` -------------------------------- ### C++: Full code listing for gas cloud example (Begin function) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/particles/3_gas_cloud.htm The `Begin` function for a C++ AGK application, demonstrating the setup of virtual resolution and loading of the particle image. This function is typically called once at the start of the application. ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::LoadImage ( 1, "particle.png" ); } ``` -------------------------------- ### Create and Position Sprites (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.htm Loads an image and creates five sprites using the AGK C++ wrapper, positioning them horizontally. This code mirrors the BASIC example for sprite initialization. ```cpp agk::LoadImage ( 1, "chip5.png" ); agk::CreateSprite ( 1, 1 ); agk::CreateSprite ( 2, 1 ); agk::CreateSprite ( 3, 1 ); agk::CreateSprite ( 4, 1 ); agk::CreateSprite ( 5, 1 ); agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpritePosition ( 2, 60, 0 ); agk::SetSpritePosition ( 3, 120, 0 ); agk::SetSpritePosition ( 4, 180, 0 ); agk::SetSpritePosition ( 5, 240, 0 ); ``` -------------------------------- ### Create and Position Sprites (AppGameKit C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.txt Loads an image and creates five sprites using the C++ syntax, then positions them horizontally. This demonstrates the equivalent setup in the C++ version of AppGameKit. ```cpp agk::LoadImage ( 1, "chip5.png" );
agk::CreateSprite ( 1, 1 ); agk::CreateSprite ( 2, 1 ); agk::CreateSprite ( 3, 1 ); agk::CreateSprite ( 4, 1 ); agk::CreateSprite ( 5, 1 );
agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpritePosition ( 2, 60, 0 ); agk::SetSpritePosition ( 3, 120, 0 ); agk::SetSpritePosition ( 4, 180, 0 ); agk::SetSpritePosition ( 5, 240, 0 ); ``` -------------------------------- ### User Input for Hosting/Joining (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Handles user input to determine whether to host or join a game using the agk:: namespace. Prints instructions to the console. ```cpp agk::Print ( "Select yellow chip to host a game" ); agk::Print ( "Select blue chip to join a game" ); if ( agk::GetPointerPressed ( ) ) { int iHit = agk::GetSpriteHit ( agk::GetPointerX ( ), agk::GetPointerY ( ) ); if ( iHit == 1 ) { NetworkID = agk::HostNetwork ( "AGK Test Game", "Player 1", 48230 ); Typ = 0; } if ( iHit == 2 ) { NetworkID = agk::JoinNetwork ( "AGK Test Game", "Player 2" ); Typ = 1; } } ``` -------------------------------- ### Full Program Setup and Execution Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/5_restitution.txt Initializes the AGK environment, loads assets, creates and positions sprites, enables physics, sets restitution levels, and runs the main loop. This provides a complete, runnable example. ```AGK Script SetVirtualResolution ( 320, 480 )
CreateSprite ( LoadImage ( "background7.jpg" ) )
LoadImage ( 1, "small_ball.png" )
CreateSprite ( 1, 1 ) CreateSprite ( 2, 1 ) CreateSprite ( 3, 1 ) CreateSprite ( 4, 1 ) CreateSprite ( 5, 1 )
SetSpritePosition ( 1, 0, 0 ) SetSpritePosition ( 2, 50, 0 ) SetSpritePosition ( 3, 100, 0 ) SetSpritePosition ( 4, 150, 0 ) SetSpritePosition ( 5, 200, 0 )
SetSpritePhysicsOn ( 1, 2 ) SetSpritePhysicsOn ( 2, 2 ) SetSpritePhysicsOn ( 3, 2 ) SetSpritePhysicsOn ( 4, 2 ) SetSpritePhysicsOn ( 5, 2 )
SetSpritePhysicsRestitution ( 1, 0.0 ) SetSpritePhysicsRestitution ( 2, 0.2 ) SetSpritePhysicsRestitution ( 3, 0.4 ) SetSpritePhysicsRestitution ( 4, 0.8 ) SetSpritePhysicsRestitution ( 5, 1.0 )
do Sync ( ) loop ``` ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 );
agk::CreateSprite ( agk::LoadImage ( "background7.jpg" ) );
agk::LoadImage ( 1, "small_ball.png" );
agk::CreateSprite ( 1, 1 ); agk::CreateSprite ( 2, 1 ); agk::CreateSprite ( 3, 1 ); agk::CreateSprite ( 4, 1 ); agk::CreateSprite ( 5, 1 );
agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpritePosition ( 2, 50, 0 ); agk::SetSpritePosition ( 3, 100, 0 ); agk::SetSpritePosition ( 4, 150, 0 ); agk::SetSpritePosition ( 5, 200, 0 );
agk::SetSpritePhysicsOn ( 1, 2 ); agk::SetSpritePhysicsOn ( 2, 2 ); agk::SetSpritePhysicsOn ( 3, 2 ); agk::SetSpritePhysicsOn ( 4, 2 ); agk::SetSpritePhysicsOn ( 5, 2 );
agk::SetSpritePhysicsRestitution ( 1, 0.0f ); agk::SetSpritePhysicsRestitution ( 2, 0.2f ); agk::SetSpritePhysicsRestitution ( 3, 0.4f ); agk::SetSpritePhysicsRestitution ( 4, 0.8f ); agk::SetSpritePhysicsRestitution ( 5, 1.0f ); }
void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Create and Position Sprites (BASIC) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/0_getting_started.htm Loads an image and creates five sprites, positioning them horizontally. This is a foundational step before enabling physics. ```basic LoadImage ( 1, "small_ball.png" ) CreateSprite ( 1, 1 ) CreateSprite ( 2, 1 ) CreateSprite ( 3, 1 ) CreateSprite ( 4, 1 ) CreateSprite ( 5, 1 ) SetSpritePosition ( 1, 0, 0 ) SetSpritePosition ( 2, 60, 0 ) SetSpritePosition ( 3, 120, 0 ) SetSpritePosition ( 4, 180, 0 ) SetSpritePosition ( 5, 240, 0 ) ``` -------------------------------- ### Full App Game Kit Physics Setup Example Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/9_physics_shapes.htm A comprehensive example demonstrating the setup of a game environment in App Game Kit, including setting virtual resolution, loading images, creating sprites with physics properties, and enabling physics debug visualization. It includes a basic game loop with synchronization. ```AGK Script SetVirtualResolution ( 320, 480 ) CreateSprite ( LoadImage ( "background3.jpg" ) ) LoadImage ( 1, "penguin.png" ) CreateSprite ( 1, 1 ) SetSpritePosition ( 1, 0, 0 ) SetSpriteShape ( 1, 3 ) SetSpritePhysicsOn ( 1, 2 ) SetSpriteScale ( 1, 0.6, 0.6 ) SetSpritePhysicsRestitution ( 1, 0.5 ) CreateSprite ( 2, 1 ) SetSpritePosition ( 2, 100, 0 ) SetSpriteShape ( 2, 1 ) SetSpritePhysicsOn ( 2, 2 ) SetSpriteScale ( 2, 0.6, 0.6 ) SetSpritePhysicsRestitution ( 2, 0.5 ) CreateSprite ( 3, 1 ) SetSpritePosition ( 3, 200, 0 ) SetSpriteShape ( 3, 2 ) SetSpritePhysicsOn ( 3, 2 ) SetSpriteScale ( 3, 0.6, 0.6 ) SetSpritePhysicsRestitution ( 3, 0.5 ) SetPhysicsDebugOn ( ) do Sync ( ) loop ``` ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::CreateSprite ( agk::LoadImage ( "background3.jpg" ) ); agk::LoadImage ( 1, "penguin.png" ); agk::CreateSprite ( 1, 1 ); agk::SetSpritePosition ( 1, 0, 0 ); agk::SetSpriteShape ( 1, 3 ); agk::SetSpritePhysicsOn ( 1, 2 ); agk::SetSpriteScale ( 1, 0.6, 0.6 ); agk::SetSpritePhysicsRestitution ( 1, 0.5 ); agk::CreateSprite ( 2, 1 ); agk::SetSpritePosition ( 2, 100, 0 ); agk::SetSpriteShape ( 2, 1 ); agk::SetSpritePhysicsOn ( 2, 2 ); agk::SetSpriteScale ( 2, 0.6, 0.6 ); agk::SetSpritePhysicsRestitution ( 2, 0.5 ); agk::CreateSprite ( 3, 1 ); agk::SetSpritePosition ( 3, 200, 0 ); agk::SetSpriteShape ( 3, 2 ); agk::SetSpritePhysicsOn ( 3, 2 ); agk::SetSpriteScale ( 3, 0.6, 0.6 ); agk::SetSpritePhysicsRestitution ( 3, 0.5 ); agk::SetPhysicsDebugOn ( ); } void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Initialize Display and Load Assets Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Sets the display aspect ratio and loads images for sprites and background. ```APIDOC ## Initialize Display and Load Assets ### Description Sets the display aspect ratio and loads the necessary images for the game sprites and background. ### Method AppGameKit Commands ### Code ```agk SetDisplayAspect ( 4.0 / 3.0 ) agk::LoadImage ( 1, "chip5.png" ); agk::LoadImage ( 2, "chip25.png" ); agk::CreateSprite ( LoadImage ( "background1b.jpg" ) ); agk::SetSpriteSize (backdrop,100,100); ``` ``` -------------------------------- ### User Input for Hosting/Joining (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Handles user input to determine whether to host or join a game based on sprite interaction. Prints instructions to the console. ```agkbasic Print ( "Select yellow chip to host a game" Print ( "Select blue chip to join a game" if GetPointerPressed ( ) = 1 hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) ) if ( hit = 1 ) NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 48230 ) Typ = 0 endif if ( hit = 2 ) NetworkID = JoinNetwork ( "AGK Test Game", "Player 2" ) Typ = 1 endif endif ``` -------------------------------- ### Full Music Playback Setup (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/sound/1_music.htm Initializes the application by creating a background sprite, loading music with a specific ID, and starting playback with looping. Includes the main application loop structure. ```C++ void app::Begin ( void ) { backdrop = agk::CreateSprite ( agk::LoadImage ( "background1b.jpg" ) ); agk::SetSpriteSize ( backdrop, 100, 100 ); agk::LoadMusicOGG ( 1, "music.ogg" ); agk::PlayMusicOGG ( 1, 1 ); } void app::Loop ( void ) { agk::Sync ( ); } ``` -------------------------------- ### Initialize and Set Up Sprites and Display (AGK) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm This code initializes the display aspect ratio, loads images for sprites, creates a background sprite, and sets up two game sprites with their initial positions and sizes. ```AGK SetDisplayAspect ( 4.0 / 3.0 ) LoadImage ( 1, "chip5.png" ) LoadImage ( 2, "chip25.png" ) bbackdrop=CreateSprite ( LoadImage ( "background1b.jpg" ) ) SetSpriteSize (backdrop,100,100) CreateSprite ( 1, 1 ) SetSpritePosition ( 1, 10, 20 ) SetSpriteSize ( 1, 10, -1 ) CreateSprite ( 2, 2 ) SetSpritePosition ( 2, 50, 20 ) SetSpriteSize ( 2, 10, -1 ) ``` -------------------------------- ### Iterate Through Clients (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Iterates through all connected clients in a network, printing each client's name. Starts with GetNetworkFirstClient and uses GetNetworkNextClient. ```agkbasic id = GetNetworkFirstClient ( NetworkID ) while id <> 0 Print ( GetNetworkClientName ( NetworkID, id ) ) id = GetNetworkNextClient ( NetworkID ) endwhile ``` -------------------------------- ### HostNetwork Command Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Initiates a network game by hosting a new session. Requires network name, player name, and a port number. ```APIDOC ## HostNetwork Command ### Description Allows a player to host a new network game. This command requires a unique network name, a name for the hosting player, and a port number for communication. ### Method AppGameKit Commands ### Parameters #### Request Body - **network name** (String) - Required - The name of the network to host. - **player name** (String) - Required - The name of the player hosting the network. - **port** (Integer) - Required - The port number for network communication (1025-65535). ### Returns - **network ID** (Integer) - An ID number for the hosted network, to be used in subsequent network operations. ``` -------------------------------- ### Iterate Through Clients (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Iterates through all connected clients in a network using the agk:: namespace, printing each client's name. Starts with GetNetworkFirstClient and uses GetNetworkNextClient. ```cpp id = agk::GetNetworkFirstClient ( NetworkID ); while ( id != 0 ) { agk::Print ( agk::GetNetworkClientName ( NetworkID, id ) ); id = agk::GetNetworkNextClient ( NetworkID ); } ``` -------------------------------- ### Full Music Playback Setup (BASIC) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/sound/1_music.htm Sets up a background sprite, loads a music file with a specific ID, and starts playing it with looping enabled. Includes the main loop for continuous execution. ```BASIC backdrop = CreateSprite ( LoadImage ( "background1b.jpg" ) ) SetSpriteSize ( backdrop, 100, 100 ) LoadMusicOGG ( 1, "music.ogg" ) PlayMusicOGG ( 1, 1 ) do Sync ( ) loop ``` -------------------------------- ### AGK: Initialize and Load Assets Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/3_simple.txt Sets the virtual resolution, creates a backdrop sprite with transparency, and loads an image for use by sprites. This is a foundational setup for any AGK application. ```agkbasic SetVirtualResolution ( 320, 480 ) backdrop = CreateSprite ( LoadImage ( "background1.jpg" ) ) SetSpriteColorAlpha ( backdrop, 40 ) LoadImage ( 2, "silver.png" ) ``` -------------------------------- ### Set Virtual Resolution and Create Sprite (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/input/0_getting_started.htm Sets the virtual resolution of the application and creates a sprite using a loaded image. The sprite is identified by an ID. ```AGK Basic SetVirtualResolution ( 320, 480 ) CreateSprite ( 1, LoadImage ( "lime.png" ) ) ``` -------------------------------- ### Host Network (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Hosts a new network game using the agk:: namespace. Requires a network name, player name, and a port number. Returns the network ID. ```cpp NetworkID = agk::HostNetwork ( "AGK Test Game", "Player 1", 48230 ); ``` -------------------------------- ### Host or Join Game Logic Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.txt Handles user input to either host a new game or join an existing one based on sprite interaction. Displays instructions to the user. ```AGK Basic Print ( "Select yellow chip to host a game" ) Print ( "Select blue chip to join a game" )
if GetPointerPressed ( ) = 1 hit = GetSpriteHit ( GetPointerX ( ), GetPointerY ( ) )
if ( hit = 1 ) NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 48230 ) Typ = 0 endif
if ( hit = 2 ) NetworkID = JoinNetwork ( "AGK Test Game", "Player 2" ) Typ = 1 endif endif ``` ```C++ agk::Print ( "Select yellow chip to host a game" ); agk::Print ( "Select blue chip to join a game" );
if ( agk::GetPointerPressed ( ) ) { int iHit = agk::GetSpriteHit ( agk::GetPointerX ( ), agk::GetPointerY ( ) );
if ( iHit == 1 ) { NetworkID = agk::HostNetwork ( "AGK Test Game", "Player 1", 48230 ); Typ = 0; }
if ( iHit == 2 ) { NetworkID = agk::JoinNetwork ( "AGK Test Game", "Player 2" ); Typ = 1; } } ``` -------------------------------- ### Host Network (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Hosts a new network game. Requires a network name, player name, and a port number. Returns the network ID. ```agkbasic NetworkID = HostNetwork ( "AGK Test Game", "Player 1", 48230 ) ``` -------------------------------- ### Set Virtual Resolution and Create Sprite (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/input/0_getting_started.htm Sets the virtual resolution and creates a sprite in C++ for App Game Kit. It loads an image and assigns it to a sprite with a specific ID. ```C++ void app::Begin ( void ) { agk::SetVirtualResolution ( 320, 480 ); agk::CreateSprite ( 1, agk::LoadImage ( "lime.png" ) ); } ``` -------------------------------- ### SetupNoise Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/Reference/Core/SetupNoise.htm Initializes Open Simplex noise generation with frequency, amplitude, lacunarity, and persistence. ```APIDOC ## SetupNoise ### Description Initializes Open Simplex noise generation. ### Method `SetupNoise` ### Parameters #### Parameters - **frequency** (float) - Frequency (width) of the first octave of noise e.g. 1.0 - **amplitude** (float) - Amplitude (height) of the first octave of noise e.g. 1.0 - **lacunarity** (float) - Lacunarity specifies the frequency multiplier between successive octaves e.g. 2.0. - **persistence** (float) - Persistence is the loss of amplitude between successive octaves (usually 1/lacunarity) ### Example ```applescript SetupNoise( 1.0, 1.0, 2.0, 0.5 ) ``` ``` -------------------------------- ### Initialize Game and Sprites (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.txt Sets up the display aspect ratio, loads images, creates a backdrop sprite, and initializes player sprites with positions and sizes. Also initializes game state variables. ```AGK Basic SetDisplayAspect ( 4.0 / 3.0 ) LoadImage ( 1, "chip5.png" ) LoadImage ( 2, "chip25.png" ) backdrop=CreateSprite ( LoadImage ( "background1b.jpg" ) ) SetSpriteSize (backdrop,100,100) CreateSprite ( 1, 1 ) SetSpritePosition ( 1, 10, 20 ) SetSpriteSize ( 1, 10, -1 ) CreateSprite ( 2, 2 ) SetSpritePosition ( 2, 50, 20 ) SetSpriteSize ( 2, 10, -1 ) State = 0 Typ = 0 NetworkID = 0 ``` -------------------------------- ### Initialize Game Setup Functions Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/guides/types_003.htm Calls the primary setup functions `SetupShip` and `SetupLasers` to initialize the game environment and player assets. ```Dark Basic SetupShip ( ) SetupLasers ( ) ``` -------------------------------- ### Control Sprite Movement with Input (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm This C++ code snippet achieves the same sprite control functionality as the AGK Basic example, utilizing the AGK C++ framework. It reads sprite position and direction, then updates the sprite's position. ```C++ if ( Typ == 0 ){ float x = agk::GetSpriteX ( 1 ) + agk::GetDirectionX ( ); float y = agk::GetSpriteY ( 1 ) + agk::GetDirectionY ( ); agk::SetSpritePosition ( 1, x, y ); } ``` -------------------------------- ### In-App Purchase Initial Setup Commands Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/guides/iap_006.htm This section details the core commands required to initialize the in-app purchase system in AppGameKit. ```APIDOC ## In-App Purchase Initial Setup ### Description This API group covers the initial commands needed to set up the in-app purchase functionality within your AppGameKit application. It includes setting the application title, providing licensing keys for Google Play, registering product IDs, and finalizing the setup. ### Method AppGameKit Commands (executed sequentially) ### Endpoint N/A (In-App Commands) ### Parameters #### InAppPurchaseSetTitle - **title** (string) - Required - The name of your application, which may appear in purchase dialogs. #### InAppPurchaseSetKeys - **publicKey** (string) - Required (for Google Play) - The public license key for your application, found in the Google Play Developer console. - **reserved** (string) - Optional - Reserved for future use. #### InAppPurchaseAddProductID - **productID** (string) - Required - The unique identifier for the in-app purchase product. - **type** (integer) - Required - The type of product: 0 for non-consumable, 1 for consumable. #### InAppPurchaseSetup - No parameters. ### Request Example ```apinonjs InAppPurchaseSetTitle("My Awesome Game"); InAppPurchaseSetKeys("YOUR_GOOGLE_PLAY_PUBLIC_KEY", ""); // Only if targeting Google Play InAppPurchaseAddProductID("com.mygame.consumable1", 1); InAppPurchaseAddProductID("com.mygame.nonconsumable1", 0); InAppPurchaseSetup(); ``` ### Response #### Success Response AppGameKit commands do not typically return a direct success/failure response in this format. Setup is confirmed by the ability to make purchases or restore them subsequently. #### Response Example N/A ``` -------------------------------- ### Join Network by IP (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Joins a hosted network game using an IP address, port number, and player name via the agk:: namespace. Returns the network ID. For internet play. ```cpp NetworkID = agk::JoinNetwork ( "123.4.5.6", 48230, "Player 2" ); ``` -------------------------------- ### Get Client Name Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.txt Retrieves the name of a specific client. Requires the network ID and the client's ID. ```AGK Basic id = GetNetworkFirstClient ( NetworkID )
name$ = GetNetworkClientName ( NetworkID, id ) ``` ```C++ id = agk::GetNetworkFirstClient ( NetworkID );
name = agk::GetNetworkClientName ( NetworkID, id ) ); ``` -------------------------------- ### Get First Client ID Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.txt Retrieves the ID of the first client connected to a network. Requires the network ID. ```AGK Basic id = GetNetworkFirstClient ( NetworkID ) ``` ```C++ id = agk::GetNetworkFirstClient ( NetworkID ); ``` -------------------------------- ### Get Client Name (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Retrieves the name of a specific client. Requires the network ID and the client's ID. ```agkbasic id = GetNetworkFirstClient ( NetworkID ) name$ = GetNetworkClientName ( NetworkID, id ) ``` -------------------------------- ### AppGameKit 'Hello World' Example 3 (Mixed Case and Spacing) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/guides/creating_first_project_005.htm This AppGameKit example showcases the case-insensitivity and flexible spacing of AppGameKit commands, printing 'hello world' with varied formatting. ```agk DO PRINT ( "hello world") SYNC() LOOP ``` -------------------------------- ### Get First Client ID (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Retrieves the ID of the first client connected to a network. Requires the network ID. ```agkbasic id = GetNetworkFirstClient ( NetworkID ) ``` -------------------------------- ### Full Program Example (AGK Basic) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/general/0_core.htm A complete example demonstrating the core AppGameKit Studio commands for retrieving device information (width, height, orientation, name) and printing them within a loop, ensuring the screen is updated with Sync(). ```basic width = GetDeviceWidth ( ) height = GetDeviceHeight ( ) orientation = GetOrientation ( ) platform$ = GetDeviceName ( ) do print ( width ) print ( height ) print ( orientation ) print ( platform$ ) Sync ( ) loop ``` -------------------------------- ### Iterate Through Clients Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.txt Iterates through all connected clients in a network, printing each client's name. Starts with the first client and continues until the end of the list. ```AGK Basic id = GetNetworkFirstClient ( NetworkID )
while id <> 0 Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID ) endwhile ``` ```C++ id = agk::GetNetworkFirstClient ( NetworkID );
while ( id != 0 ) { agk::Print ( agk::GetNetworkClientName ( NetworkID, id ) );
id = agk::GetNetworkNextClient ( NetworkID ); } ``` -------------------------------- ### AppGameKit 'Hello World' Example 1 Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/guides/creating_first_project_005.htm A basic AppGameKit program to print 'hello world' to the console. It uses standard command syntax. ```agk do print ( "hello world" ) sync ( ) loop ``` -------------------------------- ### Get Client Name (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Retrieves the name of a specific client using the agk:: namespace. Requires the network ID and the client's ID. ```cpp id = agk::GetNetworkFirstClient ( NetworkID ); name = agk::GetNetworkClientName ( NetworkID, id ) ); ``` -------------------------------- ### Set Up Particle Emitter - AGK BASIC Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/particles/2_explosions.htm Initializes the AGK environment by setting the virtual resolution, loading a particle image, and creating a particle emitter off-screen for reuse. This setup is performed once before the main loop. ```agk SetVirtualResolution ( 320, 480 ) LoadImage ( 1, "shrapnel3.png" ) CreateParticles ( 1, -100, -100 ) ``` -------------------------------- ### Get First Client ID (C++) Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/multiplayer/0_getting_started.htm Retrieves the ID of the first client connected to a network using the agk:: namespace. Requires the network ID. ```cpp id = agk::GetNetworkFirstClient ( NetworkID ); ``` -------------------------------- ### Full C++ AGK Application Example with Physics Setup Source: https://github.com/dark-basic-software-limited/agkrepo/blob/main/AGK/AGK Help Generator/AGK Txt/examples/physics/7_joints2.htm A complete C++ example for an AGK application, covering sprite and image management, physics setup for sprites and joints, applying physics impulses, enabling debug visualizations, and the main game loop. This code initializes a revolute joint and applies a force to a sprite. ```cpp void app::Begin ( void ) { agk::CreateSprite ( agk::LoadImage ( "background1.jpg" ) ); agk::LoadImage ( 1, "green.png" ); agk::LoadImage ( 2, "small_ball.png" ); agk::CreateSprite ( 1, 1 ); agk::SetSpritePosition ( 1, 150.0f, 50.0f ); agk::SetSpritePhysicsOn ( 1, 1 ); agk::CreateSprite ( 2, 2 ); agk::SetSpritePosition ( 2, 150.0f, 150.0f ); agk::SetSpritePhysicsOn ( 2, 2 ); agk::SetSpriteShape ( 2, 1 ); agk::CreateRevoluteJoint ( 1, 2, 182.0f, 82.0f, 0 ); agk::SetSpritePhysicsImpulse ( 2, 150.0f, 150.0f, 10000.0f, 0.0f ); agk::SetPhysicsDebugOn ( ); } void app::Loop ( void ) { agk::Sync ( ); } ```