Path Documentation
Paths in BeepMini are defined using a simple string-based language that allows for concise representation of movement. This documentation explains how to create and interpret these path strings.
Paths are composed of a series of commands, each represented by a letter followed by an optional number indicating how many times to execute that command. The commands can be written as uppercase or lowercase letters, with whitespace being ignored.
Path Commands
- U / D / L / R: Move Up, Down, Left, or Right.
- P: Pause for a certain number of frames.
- F: Change facing direction (followed by U, D, L, or R).
Examples
-
R4D2L4U2P3FU: Move right 4, down 2, left 4, up 2, pause 3 frames, then face up. -
u2 r3 d1 l1 p5 fd: Move up 2, right 3, down 1, left 1, pause 5 frames, then face down. -
R10D5L10U5: Move right 10, down 5, left 10, up 5.
Uses
Paths can be used to define movement patterns for characters or objects in BeepMini. Some ideas for their use include:
- Defining patrol routes for NPCs.
- Creating complex movement sequences for animations.
- Movement of platforms or obstacles.
- Scripting cutscene movements.
- Enemy movement patterns.
Path Methods
b8.Path.parseCode(code, startCol, startRow, initialDir)
Parse a path code string into an array of steps.
Commands: U - move up D - move down L - move left R - move right P - pause (stay in place) F + direction - face direction without moving (U/D/L/R)
Each command can be followed by a number to indicate how many steps to take. If no number is provided, it defaults to 1.
Examples: “UUDDLRLR” - up 2, down 2, left 1, right 1, left 1, right 1 “U2R3DL4P2” - up 2, right 3, down 1, left 4, pause 2 “FUR2FD2P3” - face up, right 2, face down 2, pause 3 “R5P” - right 5, pause 1
Parameters
- code (string): The path code string.
- startCol (number): The starting column position.
- startRow (number): The starting row position.
- initialDir (string): The initial facing direction (‘U’, ‘D’, ‘L’, ‘R’).
Returns
- (Array): Array of steps with x, y, and dir properties.
b8.Path.validPathSyntax(path)
Validates the syntax of a beepmini path string.
Parameters
- path (string): The path string to validate.
Returns
- (boolean): - True if the path syntax is valid, false otherwise.