Castagne Engine

Documentation

Castagne Engine

Getting Started

Editor

Gametypes

Intermediate

Making a Game

Pushing Castagne

Advanced

Modules

Physics 2D Reference

Physics module optimized for 2D fighting games.

Position and Movement

These functions allow basic movement and positioning for entities.

Functions

Move[1, 2][Init, Action, Manual, Subentity]
Moves the entity this frame, depending on facing.
  • Arg 1: Horizontal move
  • Arg 2: (Optional) Vertical move
MoveAbsolute[1, 2][Init, Action, Manual, Subentity]
Moves the entity this frame, independant of facing.
  • Arg 1: Horizontal move
  • Arg 2: (Optional) Vertical move
SetPositionRelativeToTarget[2][Init, Action, Manual, Subentity]
Sets the entity's position based on the target entity, dependant on its physics facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
SetPositionRelativeToTargetAbsolute[2][Init, Action, Manual, Subentity]
Sets the entity's position based on the target entity, independant of its physics facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
SetTargetPosition[2][Init, Action, Manual, Subentity]
Sets the target entity's position based on this entity, dependant of its physics facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
SetTargetPositionAbsolute[2][Init, Action, Manual, Subentity]
Sets the target entity's position based on this entity, independant of its physics facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
TargetGetRelativePosition[2][Init, Action, Manual, Subentity]
Gets the position of the target in this entity's referential.
  • Arg 1: Variable name to store the X position
  • Arg 2: Variable name to store the Y position
SetWorldPosition[2][Init, Action, Manual, Subentity]
Sets the position relative to the world origin, depending on facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
SetWorldPositionX[1][Init, Action, Manual, Subentity]
Sets the position relative to the world origin, depending on facing.
  • Arg 1: Horizontal position
SetWorldPositionY[1][Init, Action, Manual, Subentity]
Sets the position relative to the world origin, depending on facing.
  • Arg 1: Vertical position
SetWorldPositionAbsolute[2][Init, Action, Manual, Subentity]
Sets the position relative to the world origin, independant of facing.
  • Arg 1: Horizontal position
  • Arg 2: Vertical position
SetWorldPositionAbsoluteX[1][Init, Action, Manual, Subentity]
Sets the position relative to the world origin, independant of facing.
  • Arg 1: Horizontal position

Variables

_PositionX0[]
_PositionY0[]
_PrevPositionX0[]
_PrevPositionY0[]
_MovementX0[ResetEachFrame]
_MovementY0[ResetEachFrame]

Momentum

Helper functions related to momentum, applies movement from frame to frame.

Functions

AddMomentum[1, 2][Init, Action, Manual, Subentity]
Adds to the momentum, depending on facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
  • Arg 2: (Optional) Vertical momentum
AddMomentumAbsolute[1, 2][Init, Action, Manual, Subentity]
Adds to the momentum, independant of facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
  • Arg 2: (Optional) Vertical momentum
SetMomentum[2][Init, Action, Manual, Subentity]
Sets the momentum, depending on facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
  • Arg 2: Vertical momentum
SetMomentumAbsolute[2][Init, Action, Manual, Subentity]
Sets the momentum, independant of facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
  • Arg 2: Vertical momentum
SetMomentumX[1][Init, Action, Manual, Subentity]
Sets the momentum, depending on facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
SetMomentumXAbsolute[1][Init, Action, Manual, Subentity]
Sets the momentum, independant of facing. This will move the entity every frame.
  • Arg 1: Horizontal momentum
SetMomentumY[1][Init, Action, Manual, Subentity]
Sets the momentum, independant of facing. This will move the entity every frame.
  • Arg 1: Vertical momentum
BreakMomentum[1, 2][Init, Action, Manual, Subentity]
Reduces the momentum by the amount given.
  • Arg 1: Horizontal momentum
  • Arg 2: (Optional) Vertical momentum
BreakMomentumX[1, 2, 3][Init, Action, Manual, Subentity]
Reduces the horizontal momentum by the amount given.
  • Arg 1: Horizontal momentum break
  • Arg 2: (Optional) Horizontal momentum cap
  • Arg 3: (Optional) Horizontal momentum cap max
BreakMomentumY[1, 2, 3][Init, Action, Manual, Subentity]
Reduces the vertical momentum by the amount given.
  • Arg 1: Vertical momentum break
  • Arg 2: (Optional) Vertical momentum cap
  • Arg 3: (Optional) Vertical momentum cap max
BreakMomentumXAbsolute[1, 2, 3][Init, Action, Manual, Subentity]
Reduces the horizontal momentum by the amount given, independant of facing.
  • Arg 1: Horizontal momentum break
  • Arg 2: (Optional) Horizontal momentum cap
  • Arg 3: (Optional) Horizontal momentum cap max
CapMomentum[2, 4][Init, Action, Manual, Subentity]
Limits the momentum to those values.
  • Arg 1: Horizontal momentum
  • Arg 2: (Optional) Horizontal Momentum Max
  • Arg 3: Vertical momentum
  • Arg 4: (Optional) Vertical Momentum Max
CapMomentumX[2][Init, Action, Manual, Subentity]
Limits the momentum to those values.
  • Arg 1: Horizontal momentum
  • Arg 2: Horizontal Momentum Max
CapMomentumY[2][Init, Action, Manual, Subentity]
Limits the momentum to those values.
  • Arg 1: Vertical momentum
  • Arg 2: Vertical Momentum Max
CapMomentumAbsolute[2, 4][Init, Action, Manual, Subentity]
Limits the momentum to those values, independant of facing.
  • Arg 1: Horizontal momentum
  • Arg 2: (Optional) Horizontal Momentum Max
  • Arg 3: Vertical momentum
  • Arg 4: (Optional) Vertical Momentum Max
CapMomentumXAbsolute[2][Init, Action, Manual, Subentity]
Limits the momentum to those values, independant of facing.
  • Arg 1: Horizontal momentum
  • Arg 2: Horizontal Momentum Max
AddMomentumTurn[2][Init, Action, Manual, Subentity]
Adds to the momentum, depending on facing. If momentum is going in the opposite direction, cancel it before applying.
  • Arg 1: Horizontal momentum
  • Arg 2: Vertical momentum
AddMomentumTurnAbsolute[2][Init, Action, Manual, Subentity]
Adds to the momentum, independant of facing. If momentum is going in the opposite direction, cancel it before applying.
  • Arg 1: Horizontal momentum
  • Arg 2: Vertical momentum

Variables

_MomentumX0[]
_MomentumY0[]
_MomentumZ0[]

Flags

HaltMomentum

Facing

Functions relative to where the entity is facing, to handle forward / back / side directions. Several types of facing are available for various purposes.

Functions

SetFacing[1, 2][Init, Action, Manual, Subentity]
Set an entity's physics facing directly.
  • Arg 1: Horizontal Facing
  • Arg 2: (Optional) Vertical Facing
SetFacingWithType[2, 3][Init, Action, Manual, Subentity]
Set an entity's facing directly, for any type.
  • Arg 1: Type of facing to set
  • Arg 2: Horizontal Facing
  • Arg 3: (Optional) Vertical Facing
FlipFacing[0, 1, 2][Init, Action, Manual, Subentity]
Flips the horizontal facing of an entity to make it face backwards.
  • Arg 1: (Optional) Facing type (default: physics)
  • Arg 2: (Optional) Also adjust vertical facing (default: false)
FaceTowardsTarget[0, 1, 2][Init, Action, Manual, Subentity]
Faces the entity towards the target.
  • Arg 1: (Optional) Facing type (default: physics)
  • Arg 2: (Optional) Also adjust vertical facing (default: false)
TargetFaceTowardsSelf[0, 1, 2][Init, Action, Manual, Subentity]
Faces the target entity towards this entity.
  • Arg 1: (Optional) Facing type (default: physics)
  • Arg 2: (Optional) Also adjust vertical facing (default: false)
CopyTargetFacing[0, 1, 2][Init, Action, Manual, Subentity]
Copy the facing of the target entity to this entity.
  • Arg 1: (Optional) Facing type (default: physics)
  • Arg 2: (Optional) Also adjust vertical facing (default: true)
CopyFacingToTarget[0, 1, 2][Init, Action, Manual, Subentity]
Copy this entity's facing to the target entity.
  • Arg 1: (Optional) Facing type (default: physics)
  • Arg 2: (Optional) Also adjust vertical facing (default: true)
CopyFacingToOtherFacing[1, 2, 3][Init, Action, Manual, Subentity]
Copy one facing type to another facing type.
  • Arg 1: Target facing type
  • Arg 2: (Optional) Source facing type (default: physics)
  • Arg 3: (Optional) Also adjust vertical facing (default: true)
TransformLocalXToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms a local X postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalYToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms a local Y postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalZToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms a local Z postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalXYToWorld[2, 4][Init, Action, Manual, Subentity]
Transforms a local X and Y postion to a world position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformLocalToWorld[3, 6][Init, Action, Manual, Subentity]
Transforms a local XYZ postion to a world position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable
TransformWorldXToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a world X postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldYToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a world Y postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldYToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a world Z postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldXYToLocal[2, 4][Init, Action, Manual, Subentity]
Transforms a world X and Y postion to a local position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformWorldToLocal[3, 6][Init, Action, Manual, Subentity]
Transforms a world XYZ postion to a local position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable
TransformLocalXToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a local X postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalYToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a local Y postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalZToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a local Z postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformLocalXYToAbsolute[2, 4][Init, Action, Manual, Subentity]
Transforms a local X and Y postion to a absolute position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformLocalToAbsolute[3, 6][Init, Action, Manual, Subentity]
Transforms a local XYZ postion to a absolute position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable
TransformAbsoluteXToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a absolute X postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteYToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a absolute Y postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteZToLocal[1, 2][Init, Action, Manual, Subentity]
Transforms a absolute Z postion to a local position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteXYToLocal[2, 4][Init, Action, Manual, Subentity]
Transforms a absolute X and Y postion to a local position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformAbsoluteToLocal[3, 6][Init, Action, Manual, Subentity]
Transforms a absolute XYZ postion to a local position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable
TransformAbsoluteXToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms an absolute X postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteYToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms an absolute Y postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteZToWorld[1, 2][Init, Action, Manual, Subentity]
Transforms an absolute Z postion to a world position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformAbsoluteXYToWorld[2, 4][Init, Action, Manual, Subentity]
Transforms a absolute X and Y postion to a world position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformAbsoluteToWorld[3, 6][Init, Action, Manual, Subentity]
Transforms a absolute XYZ postion to a world position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable
TransformWorldXToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a world X postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldYToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a world Y postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldZToAbsolute[1, 2][Init, Action, Manual, Subentity]
Transforms a world Z postion to an absolute position.
  • Arg 1: Position to change
  • Arg 2: (Optional) Destination variable if different
TransformWorldXYToAbsolute[2, 4][Init, Action, Manual, Subentity]
Transforms a world X and Y postion to a absolute position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: (Optional) X Destination variable
  • Arg 4: (Optional) Y Destination variable
TransformWorldToAbsolute[3, 6][Init, Action, Manual, Subentity]
Transforms a world XYZ postion to a absolute position.
  • Arg 1: X position
  • Arg 2: Y Position
  • Arg 3: Z Position
  • Arg 4: (Optional) X Destination variable
  • Arg 5: (Optional) Y Destination variable
  • Arg 6: (Optional) Z Destination Variable

Variables

FACING_PHYSICS0[]
Facing type constant for the physics facing. This is used for movement.
FACING_ATTACK1[]
Facing type constant for the attack facing. This is not used for now.
FACING_BLOCK2[]
Facing type constant for the block facing. This is not used for now.
FACING_MODEL3[]
Facing type constant for the model facing. This is used for graphics.
_FacingHPhysics1[]
Horizontal physics facing.
_FacingVPhysics0[]
Vertical physics facing. Not used.
_FacingHAttack1[]
Horizontal attack facing. Not used.
_FacingVAttack0[]
Vertical attack facing. Not used.
_FacingHBlock1[]
Horizontal block facing. Not used.
_FacingVBlock0[]
Vertical block facing. Not used.
_FacingHModel1[]
Horizontal model facing.
_FacingVModel0[]
Vertical model facing. Not used.

Collisions

Environment and Attack colliders setup.

Config

AttackClashMode1[]

Functions

Colbox[2, 3, 4][Init, Action, Manual, Subentity]
Sets the collision box, which will push other entities.
  • Arg 1: Back bound (Optional)
  • Arg 2: Front bound
  • Arg 3: Down bound (Optional if only two parameters)
  • Arg 4: Up bound
SetColboxMode[0, 1][Init, Action, Manual, Subentity]
Sets the mode of the Colbox for collisions using one of the COLBOXMODE_ constants.
  • Arg 1: (Optional) Colbox mode (default: Default)
SetColboxPhantom[0, 1][Init, Action, Manual, Subentity]
Marks the Colbox as Phantom, meaning it will only collide with the environment.
  • Arg 1: (Optional) If the colbox is phantom or not (default: true)
SetColboxLayer[0, 1][Init, Action, Manual, Subentity]
Sets the layer of this colbox. By default, the layer is equal to the PID+1.
  • Arg 1: (Optional) Layer to set (Default: PID+1)
Hurtbox[2, 3, 4][Init, Action, Manual, Subentity]
Adds a hurtbox, that can be hit by hitboxes.
  • Arg 1: Back bound (Optional)
  • Arg 2: Front bound
  • Arg 3: Down bound (Optional if only two parameters)
  • Arg 4: Up bound
Hitbox[2, 3, 4][Init, Action, Manual, Subentity]
Adds a hitbox, that can hit hurtboxes. You need to set attack data beforehand, though the Attack function. This function does not reset the attack data, so you can add several hitboxes for the same attack data by calling Hitbox several times.
  • Arg 1: Back bound (Optional)
  • Arg 2: Front bound
  • Arg 3: Down bound (Optional if only two parameters)
  • Arg 4: Up bound
HurtboxRequires[0, 1][Init, Action, Manual, Subentity]
The next hurtboxes can't be hit unless the opposing attack has a specific flag. Call with no arguments to reset.
  • Arg 1: The attack flag
HurtboxAvoids[0, 1][Init, Action, Manual, Subentity]
The next hurtboxes can't be hit if the opposing attack has a specific flag. Call with no arguments to reset.
  • Arg 1: The attack flag
HitboxRequires[0, 1][Init, Action, Manual, Subentity]
The next hitboxes can't hit unless the opponent has a specific flag. Call with no arguments to reset.
  • Arg 1: The entity flag
HitboxAvoids[0, 1][Init, Action, Manual, Subentity]
The next hitboxes can't hit if the opponent has a specific flag. Call with no arguments to reset.
  • Arg 1: The entity flag
ResetColbox[0][Init, Action, Manual, Subentity]
Deletes the current colbox.
ResetHurtboxes[0][Init, Action, Manual, Subentity]
Deletes the current hurtboxes.
ResetHitboxes[0][Init, Action, Manual, Subentity]
Deletes the current hitboxes.
InflictAttack[0][Init, Action, Manual, Subentity]
Bypasses collisions and the like to register the hit directly on the target. If redoing one for the same target, replaces it.

Variables

_HurtboxMustHaves[][ResetEachFrame]
_HurtboxMustNotHaves[][ResetEachFrame]
_HitboxMustHaves[][ResetEachFrame]
_HitboxMustNotHaves[][ResetEachFrame]
_ColboxPhantom0[ResetEachFrame]
_ColboxLayer0[ResetEachFrame]
_ColboxMode0[ResetEachFrame]
COLBOXMODE_DEFAULT0[]
COLBOXMODE_OWNLAYER1[]
COLBOXMODE_OTHERLAYERS2[]
_ColboxNull[ResetEachFrame]
_Hitboxes[][ResetEachFrame]
_Hurtboxes[][ResetEachFrame]
_InflictedAttacks{}[ResetEachFrame]
_PhysicsFlagBuffer[][ResetEachFrame]

Flags

PF_Airborne
PF_Grounded
PF_Wall
PF_Ceiling
PF_Landing

Helpers

Config

AttacksCanHitOnLandingHitstunFrameFalse[]
Allows attacks to hit on a landing frame. If active, must be handled manually to avoid weird behavior.

Functions

GetTargetPositionRelativeToSelf[1, 2][Init, Action, Manual, Subentity]
Computes the position of the Target entity in this entity's physics referential, and stores it in the variables given.
  • Arg 1: The variable in which to store the X position of the target
  • Arg 2: (Optional) The variable in which to store the Y position of the target

Variables

_Gravity0[]
_TerminalVelocity-3000[]
_FrictionGround0[]
_FrictionAir0[]
_CameraX0[]
_CameraY0[]

Flags

IgnoreGravity
IgnoreFriction
NoHurtbox
NoColbox
NoHurtboxSet
NoHitboxSet
NoColboxSet

Arena

Arena setup for fighting games.

Config

UseFightingArenaTrue[]
ArenaSize180000[]
ArenaMaxPlayerDistance75000[]
PhysicsNbBuckets1[]