Skip to content

Global Scope 🌍

This section outlines globally accessible constants and type definitions used throughout the Ironclad Engine. These provide foundational values for physics, input handling, and core ECS (Entity-Component-System) structures.


Members (Constants)

These constants are primarily used by the physics system but can be accessed globally.

EPSILON

Type: number

A small numerical value used to prevent division-by-zero errors or to handle floating-point inaccuracies in calculations.


GRAVITY_X

Type: number

Defines the gravitational acceleration along the X-axis. For most 2D or 2.5D games, this is typically set to 0.


GRAVITY_Y

Type: number

Defines the gravitational acceleration along the Y-axis, measured in pixels per second squared. A positive value conventionally signifies downward acceleration.


GRAVITY_Z

Type: number

Defines the gravitational acceleration along the Z-axis. This is usually 0 if the Z-axis represents depth rather than vertical height. If Z were the primary vertical axis for movement (like jumps), this would be non-zero. For the common convention where X is horizontal, Y is screen vertical (for jumps/falls), and Z is depth, Z-axis gravity is 0.


Type Definitions

These are custom data structures used by various engine systems.

ColliderComponent

Type: object

Defines the properties for a collider component, primarily for AABB (Axis-Aligned Bounding Box) shapes used in physics and collision detection.

Properties:

NameTypeAttributesDefaultDescription
shape'aabb'The shape of the collider, currently supporting 'aabb'.
widthnumberWidth of the AABB (along the X-axis).
heightnumberHeight of the AABB (along the Y-axis).
depthnumberoptional1Depth of the AABB (along the Z-axis, can be minimal for 2D plane collision).
offsetXnumberoptional0Offset of the collider's center from the entity's X position.
offsetYnumberoptional0Offset of the collider's center from the entity's Y position.
offsetZnumberoptional0Offset of the collider's center from the entity's Z position.
isTriggerbooleanoptionalfalseIf true, this collider detects overlaps but doesn't cause physical responses.
collisionLayernumberoptional1A bitmask representing the layer(s) this collider belongs to.
collisionMasknumberoptional1A bitmask representing the layer(s) this collider can interact with.
collidesWithTilesbooleanoptionaltrueWhether this collider should check for collisions with tilemap collision layers.

ComponentData

Type: number

A unique identifier for an entity.

Engine Clarification: While named ComponentData in this global typedef, the description and type (number) strongly suggest this refers to what is commonly known as an EntityId. Actual component data structures are typically objects with various properties.


ComponentDefinition

Type: object

Used by the PrefabManager to define a component and its initial data when creating entities from prefabs.

Properties:

NameTypeDescription
typestring(Inferred) The type/name of the component.
dataobjectThe initial data for the component.

GamepadAxisBinding

Type: object

Defines a binding for a gamepad axis input to an action.

Properties:

NameTypeAttributesDefaultDescription
type'gamepadAxis'Identifies this as a gamepad axis binding.
axisIndexnumberThe index of the gamepad axis (e.g., 0 for left stick X, 1 for left stick Y).
directionnumberThe direction to check for: 1 for positive values, -1 for negative values.
thresholdnumberoptional0.5The absolute value the axis must exceed to be considered active.
padIndexnumberoptional0The index of the gamepad (controller) if multiple are connected.

GamepadButtonBinding

Type: object

Defines a binding for a gamepad button input to an action.

Properties:

NameTypeAttributesDefaultDescription
type'gamepadButton'Identifies this as a gamepad button binding.
buttonIndexnumberThe index of the gamepad button (e.g., 0 for A/Cross, 1 for B/Circle).
padIndexnumberoptional0The index of the gamepad (controller) if multiple are connected.

InputBinding

Type: KeyBinding | MouseBinding | GamepadButtonBinding | GamepadAxisBinding

A union type representing any of the possible input binding configurations used by the InputManager to map physical inputs to game actions.


KeyBinding

Type: object

Defines a binding for a keyboard key input to an action.

Properties:

NameTypeDescription
type'key'Identifies this as a keyboard key binding.
codestringThe event.code value for the keyboard key (e.g., "KeyW", "Space", "ArrowUp").

MouseBinding

Type: object

Defines a binding for a mouse button input to an action.

Properties:

NameTypeDescription
type'mouse'Identifies this as a mouse button binding.
buttonnumberThe mouse button code (e.g., 0 for left, 1 for middle, 2 for right). Refer to InputManager.MOUSE_BUTTON_LEFT etc. for constants.

PhysicsBodyComponent

Type: object

Defines the properties for a physics body, determining how an entity interacts with the physics simulation.

Properties:

NameTypeAttributesDefaultDescription
entityType'dynamic'|'static''dynamic' entities are affected by forces and collisions; 'static' are immovable.
useGravitybooleanoptionalfalseIf true, the entity is affected by global gravity.
gravityScalenumberoptional1.0Multiplier for the global gravity's effect on this specific entity.
isOnGroundbooleanoptionaltrueIndicates if the entity is currently resting on a surface.

PositionComponent

Type: object

Represents an entity's position in the game world, typically using 2D or 3D coordinates.

Properties:

NameTypeAttributesDefaultDescription
xnumberThe entity's world x-coordinate.
ynumberThe entity's world y-coordinate.
znumberoptional0The entity's world z-coordinate (used for layering or 3D depth).

PrefabDefinition

Type: object

Defines the structure of a "prefab" (prefabricated entity template), used by the PrefabManager to instantiate complex entities with a predefined set of components and initial data.

Properties:

NameTypeAttributesDescription
descriptionstringoptionalAn optional human-readable description of the prefab.
componentsArray<ComponentDefinition>An array of component definitions that make up this prefab.

ProcessedTileset

Type: object

Represents a tileset after it has been processed and its image asset loaded, ready for use by the TileLayerRenderer.

Properties:

NameTypeDescription
firstgidnumberThe first global tile ID in this tileset.
imageHTMLImageElementThe loaded image element for the tileset.
namestringThe name of the tileset.
tileWidthnumberThe width of a single tile in pixels.
tileHeightnumberThe height of a single tile in pixels.
columnsnumberThe number of tile columns in the tileset image.
imageWidthnumberThe total width of the tileset image in pixels.
imageHeightnumberThe total height of the tileset image in pixels.
spacingnumberThe spacing (in pixels) between adjacent tiles in the image.
marginnumberThe margin (in pixels) around the tiles in the image.

VelocityComponent

Type: object

Represents an entity's velocity, indicating its speed and direction of movement along the X, Y, and optionally Z axes.

Properties:

NameTypeAttributesDefaultDescription
vxnumberVelocity on the x-axis, typically in pixels per second.
vynumberVelocity on the y-axis, typically in pixels per second.
vznumberoptional0Velocity on the z-axis (if used for 3D movement or depth changes).

Released under the MIT License (Placeholder).