### Instant Playable Game Setup with VibeGame CDN Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how to quickly set up a playable 3D game using the VibeGame CDN. It includes a ground to prevent falling and initializes the game with default player, camera, and lighting. The script tag loads the standalone VibeGame library, and the world tag defines the game environment. Finally, GAME.run() starts the game loop. ```html ``` -------------------------------- ### Camera Recipe Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Describes the 'camera' recipe for creating an orbital camera setup. ```APIDOC ## Camera Recipe ### Description The 'camera' recipe provides a convenient way to set up an orbital camera with default configurations. It automatically includes the necessary components for an orbital camera system. ### Recipe #### camera - **Description**: Creates an orbital camera with default settings. - **Components**: `orbit-camera`, `transform`, `world-transform`, `main-camera`. ``` -------------------------------- ### Basic Camera Setup Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Defines a default orbital camera for the scene. ```APIDOC ## Basic Camera Setup ### Description Creates a default orbital camera for the scene. ### Method XML Configuration ### Endpoint N/A ### Parameters N/A ### Request Example ```xml ``` ### Response N/A ``` -------------------------------- ### Player Setup and Configuration Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how to set up and configure the player entity in VibeGame using XML or JavaScript. ```APIDOC ## Player Setup and Configuration ### Description This section covers different methods for setting up and customizing the player entity within the VibeGame engine. ### Examples #### Basic Player Usage (XML) ```xml ``` #### Custom Player Configuration (XML) ```xml ``` #### Accessing Player Component (JavaScript) ```typescript import * as GAME from 'vibegame'; const playerQuery = GAME.defineQuery([GAME.Player]); const MySystem: GAME.System = { update: (state) => { const players = playerQuery(state.world); for (const entity of players) { // Check if player is jumping if (GAME.Player.isJumping[entity]) { console.log('Player is airborne!'); } // Modify player speed GAME.Player.speed[entity] = 10; } } }; ``` #### Creating Player Programmatically ```typescript import * as GAME from 'vibegame'; const PlayerSpawnSystem: GAME.System = { setup: (state) => { // Create player entity const player = state.createEntity(); // Add player recipe components state.addComponent(player, GAME.Player, { speed: 7, jumpHeight: 3.5, cameraSensitivity: 0.01 }); // Add required components state.addComponent(player, GAME.Transform, { posY: 5 }); state.addComponent(player, GAME.Body, { type: GAME.BodyType.KinematicPositionBased }); state.addComponent(player, GAME.CharacterController); state.addComponent(player, GAME.InputState); } }; ``` ``` -------------------------------- ### Plugin Registration Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Example of how to register plugins, specifically the PlayerPlugin. ```APIDOC ## Plugin Registration ### Description Demonstrates how to register plugins with the VibeGame engine. ### Examples ```typescript import * as GAME from 'vibegame'; GAME .withPlugin(GAME.PlayerPlugin) // Included in defaults .run(); ``` ``` -------------------------------- ### Basic Rendering Setup Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates setting up a basic scene with a canvas, sky color, lighting, and rendered entities like boxes and spheres using XML. ```APIDOC ## Basic Rendering Setup ### Description Sets up a declarative scene with lighting and rendered objects. ### Method Declarative XML configuration ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```xml ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Basic Player Setup (XML) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates the basic XML configuration for setting up a player entity with default physics properties. ```xml ``` -------------------------------- ### Plugin System Usage Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Examples of how to use specific plugins or the default plugin bundle in VibeGame. ```APIDOC ## Plugin System ### Using Specific Plugins ```typescript import * as GAME from 'vibegame'; // Start with no plugins GAME .withoutDefaultPlugins() .withPlugin(TransformsPlugin) // Just transforms .withPlugin(RenderingPlugin) // Add rendering .withPlugin(PhysicsPlugin) // Add physics .run(); ``` ### Default Plugin Bundle - **RecipesPlugin** - XML parsing and entity creation - **TransformsPlugin** - Position, rotation, scale, hierarchy - **RenderingPlugin** - Three.js meshes, lights, camera - **PhysicsPlugin** - Rapier physics simulation - **InputPlugin** - Keyboard, mouse, gamepad input - **OrbitCameraPlugin** - Third-person camera - **PlayerPlugin** - Character controller - **TweenPlugin** - Animation system - **RespawnPlugin** - Fall detection and reset - **StartupPlugin** - Auto-create player/camera/lights ``` -------------------------------- ### Basic Plugin Auto-Creation with VibeGame Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how the VibeGame plugin automatically creates default entities like player, camera, and lighting when the game runs. This is the simplest way to get started. ```typescript import * as GAME from 'vibegame'; // This will create player, camera, and lighting automatically GAME.run(); // Uses DefaultPlugins which includes StartupPlugin ``` -------------------------------- ### Physics Playground Setup in XML Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Creates a physics simulation environment with a ground, walls, and several dynamic spheres. Includes examples of spawning spheres at different positions and creating a bouncy ball with a high restitution value. Uses 'static-part', 'dynamic-part', and 'collider' attributes. ```xml ``` -------------------------------- ### VibeGame Development Setup and Commands Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Provides instructions for setting up a VibeGame project locally using npm and running development commands. It outlines the typical project structure, including TypeScript support and configuration files. Key commands for development, building, previewing, and code quality checks are listed. ```bash npm create vibegame@latest my-game cd my-game bun dev # Start dev server with hot reload ``` ```bash bun run build bun run preview bun run check bun run lint bun run format ``` -------------------------------- ### Basic Rendering Setup in XML Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Sets up a basic 3D scene using XML. It defines a canvas for rendering, sky color, default lighting, and renders a red box and a green sphere at specified positions. ```xml ``` -------------------------------- ### JavaScript API: Character Movement Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Example of implementing character movement, including jumping and platform interaction. ```APIDOC ## JavaScript API: Character Movement ### Description Example of implementing character movement, including jumping and platform interaction. ### Method JavaScript ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import * as GAME from 'vibegame'; const PlayerMovementSystem: GAME.System = { update: (state) => { const movementQuery = GAME.defineQuery([GAME.CharacterMovement, GAME.CharacterController]); for (const entity of movementQuery(state.world)) { // Set desired movement based on input GAME.CharacterMovement.desiredVelX[entity] = input.x * 5; GAME.CharacterMovement.desiredVelZ[entity] = input.z * 5; // Jump if grounded if (GAME.CharacterController.grounded[entity] && input.jump) { GAME.CharacterMovement.velocityY[entity] = 10; } } } }; ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Animation System Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Details on the animation system, including components, systems, and examples for character animation. ```APIDOC ### Animation Procedural character animation with body parts that respond to movement states. ### Components #### AnimatedCharacter - headEntity: eid - torsoEntity: eid - leftArmEntity: eid - rightArmEntity: eid - leftLegEntity: eid - rightLegEntity: eid - phase: f32 - Walk cycle phase (0-1) - jumpTime: f32 - fallTime: f32 - animationState: ui8 - 0=IDLE, 1=WALKING, 2=JUMPING, 3=FALLING, 4=LANDING - stateTransition: f32 #### HasAnimator Tag component (no properties) ### Systems #### AnimatedCharacterInitializationSystem - Group: setup - Creates body part entities for AnimatedCharacter components #### AnimatedCharacterUpdateSystem - Group: simulation - Updates character animation based on movement and physics state #### Examples ### Basic Usage ```typescript import * as GAME from 'vibegame'; // Add animated character to a player entity const player = state.createEntity(); state.addComponent(player, GAME.AnimatedCharacter); state.addComponent(player, GAME.CharacterController); state.addComponent(player, GAME.Transform); // The AnimatedCharacterInitializationSystem will automatically // create body parts in the next setup phase ``` ``` -------------------------------- ### TypeScript Context7 Library Documentation Fetch Source: https://github.com/dylanebert/vibegame/blob/main/agents.md Illustrates how AI agents with Context7 access can retrieve detailed documentation for the 'vibegame' library. It outlines the process of resolving the library ID and then fetching its documentation, which is described as over 2000 lines long with extensive examples. ```typescript // For AI agents with Context7 access: // Use mcp__context7__resolve-library-id to find "vibegame" // Then use mcp__context7__get-library-docs with the resolved ID // This provides the full 2000+ line documentation with detailed examples ``` -------------------------------- ### JavaScript API: Create Physics Entity Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Example of creating a dynamic physics box using the VibeGame JavaScript API. ```APIDOC ## JavaScript API: Create Physics Entity ### Description Example of creating a dynamic physics box using the VibeGame JavaScript API. ### Method JavaScript ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import * as GAME from 'vibegame'; // Create a dynamic physics box const entity = state.createEntity(); state.addComponent(entity, GAME.Body, { type: GAME.BodyType.Dynamic, mass: 5, posX: 0, posY: 10, posZ: 0 }); state.addComponent(entity, GAME.Collider, { shape: GAME.ColliderShape.Box, sizeX: 1, sizeY: 1, sizeZ: 1, friction: 0.7, restitution: 0.3 }); // Note: Physics body won't exist until next fixed update // Transform will be overwritten by Body position after initialization ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Basic Platformer Scene Setup in XML Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Defines a simple platformer game environment. Includes static ground and platforms, a moving platform controlled by a tween animation, and a goal area. Entities are defined using various part recipes like static-part and kinematic-part. ```xml ``` -------------------------------- ### XML with Transform Sync for Respawn Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Illustrates how position and rotation attributes defined in XML for entities like `` automatically populate the 'transform' and 'respawn' components, simplifying initial setup. ```xml ``` -------------------------------- ### Creating Player Programmatically (JavaScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Provides an example of programmatically creating a player entity and adding necessary components like Player, Transform, Body, CharacterController, and InputState. ```typescript import * as GAME from 'vibegame'; const PlayerSpawnSystem: GAME.System = { setup: (state) => { // Create player entity const player = state.createEntity(); // Add player recipe components state.addComponent(player, GAME.Player, { speed: 7, jumpHeight: 3.5, cameraSensitivity: 0.01 }); // Add required components state.addComponent(player, GAME.Transform, { posY: 5 }); state.addComponent(player, GAME.Body, { type: GAME.BodyType.KinematicPositionBased }); state.addComponent(player, GAME.CharacterController); state.addComponent(player, GAME.InputState); } }; ``` -------------------------------- ### Bash VibeGame Development Commands Source: https://github.com/dylanebert/vibegame/blob/main/agents.md Provides essential bash commands for managing and developing VibeGame projects. This includes creating a new project, starting the development server, building for production, running TypeScript checks, linting with auto-fix, and executing tests. ```bash # Project creation npm create vibegame@latest my-game cd my-game # Development bun dev # Start dev server bun run build # Production build bun run check # TypeScript validation bun run lint --fix # ESLint analysis bun test # Run tests ``` -------------------------------- ### Manual VibeGame Plugin Registration Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Illustrates the process of manually registering VibeGame plugins. This approach allows for fine-grained control over which plugins are included in the game loop, starting with only essential plugins like Transforms, Rendering, and Startup. ```typescript import * as GAME from 'vibegame'; // Use startup plugin without other defaults GAME.withoutDefaultPlugins() .withPlugin(GAME.TransformsPlugin) .withPlugin(GAME.RenderingPlugin) .withPlugin(GAME.StartupPlugin) .run(); ``` -------------------------------- ### VibeGame Recipe Internals Example Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Illustrates how recipes like '' are registered component bundles with default properties. It shows how explicit property overrides within a recipe definition affect the final entity's components. ```xml collider renderer respawn > collider renderer="color: 0xff0000" respawn > ``` -------------------------------- ### Register InputPlugin in VibeGame (TypeScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt This example demonstrates how to register the InputPlugin with the VibeGame engine using a fluent API before running the game. This enables focus-aware input handling for mouse, keyboard, and gamepad. ```typescript import * as GAME from 'vibegame'; GAME .withPlugin(GAME.InputPlugin) .run(); ``` -------------------------------- ### Manual Respawn Component Setup in XML Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Adds a manual respawn component to an entity using XML. This allows specifying a custom respawn position for entities that fall below a certain Y-coordinate, defined by the 'respawn' attribute. ```xml ``` -------------------------------- ### Basic XML Tween Example Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Animates the Y position of a kinematic body from 5 to 10 over 2 seconds using a sine-in-out easing function and a ping-pong loop mode. ```xml ``` -------------------------------- ### Imperative Respawn Component Setup with TypeScript Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how to add and configure the 'Respawn' component to an entity programmatically using TypeScript. It sets the initial spawn position and rotation, which will be used when the entity respawns. ```typescript import * as GAME from 'vibegame'; // Add respawn to an entity const entity = state.createEntity(); // Set spawn point from current transform state.addComponent(entity, GAME.Transform, { posX: 0, posY: 10, posZ: 0, eulerX: 0, eulerY: 0, eulerZ: 0 }); state.addComponent(entity, GAME.Respawn, { posX: 0, posY: 10, posZ: 0, eulerX: 0, eulerY: 0, eulerZ: 0 }); // Entity will respawn at (0,10,0) when falling ``` -------------------------------- ### XML Entity Transforms Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Provides examples of setting entity transforms (position, rotation, scale) using XML attributes in VibeGame. It covers setting individual properties and combining them. ```xml ``` -------------------------------- ### VibeGame Transform Interpolation Example Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Provides a code snippet demonstrating how to interpolate between two positions for an entity's Transform component in VibeGame. This is useful for smooth animations and movement. ```typescript import * as GAME from 'vibegame'; // Interpolate between two positions const t = 0.5; // 50% between start and end GAME.Transform.posX[entity] = startX + (endX - startX) * t; GAME.Transform.posY[entity] = startY + (endY - startY) * t; GAME.Transform.posZ[entity] = startZ + (endZ - startZ) * t; ``` -------------------------------- ### VibeGame Component Requirement Pitfall Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Highlights a common mistake where entities are defined without their required components, leading to errors. It contrasts bad examples with good and best practices using explicit components and recipes. ```xml ``` -------------------------------- ### VibeGame Customization of Auto-Created Elements Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how to override VibeGame's default auto-created elements like the player, camera, and lighting. The example shows custom XML tags within the `` element to specify unique properties such as player spawn position and speed, camera distance and pitch, and detailed ambient and directional light settings. ```xml ``` -------------------------------- ### Customize Input Mappings in VibeGame (TypeScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt This snippet shows how to customize default input mappings and sensitivity settings in VibeGame before the game starts. It modifies key bindings for jumping and moving forward, and adjusts mouse sensitivity for looking. ```typescript import * as GAME from 'vibegame'; // Modify before starting the game GAME.INPUT_CONFIG.mappings.jump = ['Space', 'KeyX']; GAME.INPUT_CONFIG.mappings.moveForward = ['KeyW', 'KeyZ', 'ArrowUp']; GAME.INPUT_CONFIG.mouseSensitivity.look = 0.3; GAME.run(); ``` -------------------------------- ### Consume Buffered Actions in VibeGame (TypeScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt This example illustrates how to consume buffered input actions like jumping or primary actions within a VibeGame system. Consuming an action ensures it's only processed once per available input, preventing issues like double jumps. ```typescript import * as GAME from 'vibegame'; const CombatSystem: GAME.System = { update: (state) => { // Consume jump if available (prevents double consumption) if (GAME.consumeJump()) { // Perform jump velocity.y = JUMP_FORCE; } // Consume primary action if (GAME.consumePrimary()) { // Fire weapon spawnProjectile(); } } }; ``` -------------------------------- ### VibeGame Physics Objects: Static, Dynamic, Kinematic Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Illustrates the creation of different types of physics objects in VibeGame using XML. It shows how to define static (immovable) parts, dynamic (gravity-affected) parts, and kinematic (script-controlled) parts. The example for kinematic parts includes a tween animation for movement. ```xml ``` -------------------------------- ### VibeGame ECS Component and System Definition Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Illustrates the core concepts of the Entity-Component-System (ECS) architecture in VibeGame using TypeScript. It shows how to define a simple component with data (e.g., Health) and how to create a system (e.g., DamageSystem) that operates on entities possessing that component. The DamageSystem example demonstrates updating component data and destroying entities. ```typescript // Component = Data only const Health = GAME.defineComponent({ current: GAME.Types.f32, max: GAME.Types.f32 }); // System = Logic only const healthQuery = GAME.defineQuery([Health]); const DamageSystem: GAME.System = { update: (state) => { const entities = healthQuery(state.world); for (const entity of entities) { Health.current[entity] -= 1 * state.time.deltaTime; if (Health.current[entity] <= 0) { state.destroyEntity(entity); } } } }; ``` -------------------------------- ### Startup Systems Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Describes the startup systems that automatically create essential entities like players, cameras, and lighting if they are missing. ```APIDOC ## Startup Systems ### Description Auto-creates player, camera, and lighting entities at startup if they are missing. ### Method Automatic system initialization ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example N/A ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Entity Component System in XML Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates VibeGame's entity-component system where XML tags represent entities and attributes define components. Shows how recipes like `` are shortcuts for `` with predefined components. Explains using bare attributes for default components and valued attributes for customization. ```xml ``` -------------------------------- ### Rendering Components and Systems Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Documentation for rendering-related components and systems, including lights, post-processing, and mesh synchronization. ```APIDOC ## Rendering Components and Systems ### Description This section details the components and systems involved in rendering the game world, including visual elements, lighting, and post-processing effects. ### Components #### Renderer - shape: ui8 - 0=box, 1=sphere, 2=cylinder, 3=plane - sizeX, sizeY, sizeZ: f32 (1) - color: ui32 (0xffffff) - visible: ui8 (1) #### RenderContext - clearColor: ui32 (0x000000) - hasCanvas: ui8 #### MainCamera Tag component (no properties) #### Ambient - skyColor: ui32 (0x87ceeb) - groundColor: ui32 (0x4a4a4a) - intensity: f33 (0.6) #### Directional - color: ui32 (0xffffff) - intensity: f32 (1) - castShadow: ui8 (1) - shadowMapSize: ui32 (4096) - directionX: f32 (-1) - directionY: f32 (2) - directionZ: f32 (-1) - distance: f32 (30) #### Bloom - intensity: f32 (1.0) - Bloom intensity - luminanceThreshold: f32 (1.0) - Luminance threshold for bloom - luminanceSmoothing: f32 (0.03) - Smoothness of luminance threshold - mipmapBlur: ui8 (1) - Enable mipmap blur - radius: f32 (0.85) - Blur radius for mipmap blur - levels: ui8 (8) - Number of MIP levels for mipmap blur #### Dithering - colorBits: ui8 (4) - Bits per color channel (1-8) - intensity: f32 (1.0) - Effect intensity (0-1) - grayscale: ui8 (0) - Enable grayscale mode (0/1) - scale: f32 (1.0) - Pattern scale (higher = coarser dithering) - noise: f32 (1.0) - Noise threshold intensity ### Systems #### MeshInstanceSystem - Group: draw - Synchronizes transforms with Three.js meshes #### LightSyncSystem - Group: draw - Updates Three.js lights #### CameraSyncSystem - Group: draw - Updates Three.js camera and manages post-processing effects #### WebGLRenderSystem - Group: draw (last) - Renders scene through EffectComposer ### Functions #### setCanvasElement(entity, canvas): void Associates canvas with RenderContext ``` -------------------------------- ### Physics Systems Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Lists the various systems involved in the physics simulation, from initialization to step and synchronization. ```APIDOC ## Physics Systems ### Description Outlines the different systems responsible for managing the physics simulation, including initialization, updates, and synchronization between the physics engine and the ECS. ### Method System Definitions ### Endpoint N/A ### Parameters N/A ### Systems - PhysicsWorldSystem - Initializes physics world - PhysicsInitializationSystem - Creates bodies and colliders - PhysicsCleanupSystem - Removes physics on entity destroy - PlatformDeltaSystem - Tracks platform position changes - CharacterMovementSystem - Character controller movement with platform sticking - CollisionEventCleanupSystem - Clears collision events - ApplyForcesSystem - Applies forces - ApplyTorquesSystem - Applies torques - ApplyImpulsesSystem - Applies impulses - ApplyAngularImpulsesSystem - Applies angular impulses - SetVelocitySystem - Sets velocities - TeleportationSystem - Instant position changes - KinematicMovementSystem - Kinematic movement - PhysicsStepSystem - Steps simulation - PhysicsRapierSyncSystem - Syncs Rapier to ECS - PhysicsInterpolationSystem - Interpolates for rendering ### Response N/A ``` -------------------------------- ### Plugin Registration (JavaScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Demonstrates how to register the PlayerPlugin using a fluent API chain before running the game. ```typescript import * as GAME from 'vibegame'; GAME .withPlugin(GAME.PlayerPlugin) // Included in defaults .run(); ``` -------------------------------- ### Core Math Utilities Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Documentation for core math utilities including interpolation functions, their usage, and recommendations. ```APIDOC ## Plugin Reference ### Core Math utilities for interpolation and 3D transformations. ### Functions #### lerp(a, b, t): number Linear interpolation #### slerp(fromX, fromY, fromZ, fromW, toX, toY, toZ, toW, t): Quaternion Quaternion spherical interpolation #### Examples ## Usage Note Math utilities are used internally by systems like tweening and transforms. For animating properties, use the Tween system instead of directly calling interpolation functions. For transformations, use the Transform component's euler angles which are automatically converted to quaternions by the system. ``` -------------------------------- ### Custom Input Mappings Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Shows how to customize input mappings and mouse sensitivity settings before running the game. ```APIDOC ## Custom Input Mappings ### Description This example illustrates how to modify the default input configurations, such as changing the keys mapped to 'jump' and 'moveForward', and adjusting mouse sensitivity for looking. These changes are applied before the game is run. ### Method Configuration ### Endpoint N/A ### Parameters None ### Request Example ```typescript import * as GAME from 'vibegame'; // Modify before starting the game GAME.INPUT_CONFIG.mappings.jump = ['Space', 'KeyX']; GAME.INPUT_CONFIG.mappings.moveForward = ['KeyW', 'KeyZ', 'ArrowUp']; GAME.INPUT_CONFIG.mouseSensitivity.look = 0.3; GAME.run(); ``` ### Response Allows developers to tailor input controls to their specific game requirements. ``` -------------------------------- ### Basic Plugin Registration Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Shows the basic process of registering the InputPlugin with the VibeGame engine. ```APIDOC ## Basic Plugin Registration ### Description This example demonstrates how to include the `InputPlugin` into the game's plugin system and then run the game. ### Method Plugin Registration and Game Run ### Endpoint N/A ### Parameters None ### Request Example ```typescript import * as GAME from 'vibegame'; GAME .withPlugin(GAME.InputPlugin) .run(); ``` ### Response Starts the VibeGame engine with input handling enabled. ``` -------------------------------- ### Idempotent Startup Systems in VibeGame Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Explains that VibeGame's startup systems are idempotent, meaning they check for existing entities before creating them. This prevents duplicate entities on subsequent runs. ```typescript import * as GAME from 'vibegame'; // First run: Creates player, camera, lights const playerQuery = GAME.defineQuery([GAME.Player]); playerQuery(state.world).length // 0 -> creates player // Subsequent runs: Skips creation playerQuery(state.world).length // 1 -> skips creation ``` -------------------------------- ### Manual Event Handling in VibeGame (TypeScript) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt This example demonstrates how to manually attach VibeGame's input event handlers to a canvas element. This approach is useful when you need more control over event processing or are integrating VibeGame with existing event listeners. ```typescript import * as GAME from 'vibegame'; // Use the exported handlers directly if needed canvas.addEventListener('mousedown', GAME.handleMouseDown); canvas.addEventListener('mouseup', GAME.handleMouseUp); ``` -------------------------------- ### Input Handling and Components Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Details the `InputState` component and related system functions for managing user input. ```APIDOC ## Input Handling and Components ### Description Provides details on the `InputState` component, which holds various input values like movement axes, mouse deltas, and button states. It also outlines functions to set the target canvas for input, consume buffered actions, and handle raw input events. ### Components #### InputState - **moveX** (f32) - Horizontal movement axis (-1 left, 1 right) - **moveY** (f32) - Forward/backward movement axis (-1 back, 1 forward) - **moveZ** (f32) - Vertical movement axis (-1 down, 1 up) - **lookX** (f32) - Mouse delta X - **lookY** (f32) - Mouse delta Y - **scrollDelta** (f32) - Mouse wheel delta - **jump** (ui8) - Jump input state (0/1) - **primaryAction** (ui8) - Primary action input state (0/1) - **secondaryAction** (ui8) - Secondary action input state (0/1) - **leftMouse** (ui8) - Left mouse button state (0/1) - **rightMouse** (ui8) - Right mouse button state (0/1) - **middleMouse** (ui8) - Middle mouse button state (0/1) - **jumpBufferTime** (f32) - Time for jump input buffering - **primaryBufferTime** (f32) - Time for primary action input buffering - **secondaryBufferTime** (f32) - Time for secondary action input buffering ### Systems #### InputSystem - **Group**: simulation - **Description**: Updates `InputState` components with current input data. ### Functions #### setTargetCanvas - **Description**: Registers a canvas element for focus-based keyboard input. - **Parameters**: `canvas` (HTMLCanvasElement | null) - **Returns**: void #### consumeJump - **Description**: Consumes buffered jump input. - **Returns**: boolean #### consumePrimary - **Description**: Consumes buffered primary action input. - **Returns**: boolean #### consumeSecondary - **Description**: Consumes buffered secondary action input. - **Returns**: boolean #### handleMouseMove - **Description**: Processes mouse movement events. - **Parameters**: `event` (MouseEvent) - **Returns**: void #### handleMouseDown - **Description**: Processes mouse button press events. - **Parameters**: `event` (MouseEvent) - **Returns**: void #### handleMouseUp - **Description**: Processes mouse button release events. - **Parameters**: `event` (MouseEvent) - **Returns**: void #### handleWheel - **Description**: Processes mouse wheel events. - **Parameters**: `event` (WheelEvent) - **Returns**: void ``` -------------------------------- ### XML Game World Definition Source: https://github.com/dylanebert/vibegame/blob/main/agents.md Defines the game world with a sky color and includes examples of static, dynamic, and kinematic physics objects. Static parts are immovable, dynamic parts are affected by gravity, and kinematic parts are controlled by scripts using tweens. ```xml ``` -------------------------------- ### JavaScript API: Apply Forces Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Shows how to apply forces, impulses, and set velocities for physics entities. ```APIDOC ## JavaScript API: Apply Forces ### Description Shows how to apply forces, impulses, and set velocities for physics entities. ### Method JavaScript ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```typescript import * as GAME from 'vibegame'; // Apply upward impulse (jump) state.addComponent(entity, GAME.ApplyImpulse, { x: 0, y: 50, z: 0 }); // Apply continuous force state.addComponent(entity, GAME.ApplyForce, { x: 10, y: 0, z: 0 }); // Set velocity directly state.addComponent(entity, GAME.SetLinearVelocity, { x: 0, y: 5, z: 0 }); ``` ### Response #### Success Response (200) N/A #### Response Example N/A ``` -------------------------------- ### Configure Camera to Follow Player Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt This XML configuration sets up a camera to follow a specified player entity. It allows customization of the target, distance, and vertical offset for a smooth following behavior. ```xml ``` -------------------------------- ### Physics Initialization Function Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Details the function used to initialize the Rapier WASM physics engine. ```APIDOC ## Physics Initialization Function ### Description Provides information about the `initializePhysics` function, which is responsible for initializing the Rapier WebAssembly physics engine. ### Method Function Definition ### Endpoint N/A ### Parameters N/A ### Functions #### initializePhysics(): Promise Initializes Rapier WASM physics engine ### Response N/A ``` -------------------------------- ### Custom Player Configuration (XML) Source: https://github.com/dylanebert/vibegame/blob/main/llms.txt Shows how to customize player properties like position, speed, jump height, rotation speed, and camera sensitivity via XML. ```xml ```