Documentation - CrackThrough/ADOFAI-WebModule GitHub Wiki

ADOFAI class

Non-static

Static

[Non-static] pathData

pathData is an array of ADOFAI.PathData class' instance.

Usage is the same as a normal array. It is a normal array.

[Non-static] settings

settings Object is a copy of another object ADOFAI.Settings.

ADOFAI.Settings value is close to default. It is not the same, here's a list of changes I made:

  • zoom
  • all colors

I highly suggest you use ADOFAI.Enums when needed.

[Non-static] actions

actions is an array of ADOFAI.Action class' instance.

Usage is the same as a normal array. It is a normal array.

[Non-static] Export()

Exports the level into a string.

[Static] Color

Color is a class for ADOFAI's hexadecimal string support.

You can create an instance of this class by doing new ADOFAI.Color("ffffff");

Color class includes 2 functions and 3 properties.

Properties:

  • R (intensity of red in color, should be int and between 0 ~ 255.)
  • G (intensity of green in color, should be int and between 0 ~ 255.)
  • B (intensity of blue in color, should be int and between 0 ~ 255.)

Functions:

  • toNumber()
  • toString() (result does not start with "#" and decimals will be truncated, value bigger than 255 or smaller than 0 will be replaced to nearest possible value.)

[Static] Enums

Enums is enum-like Object with hardcoded values.

There are a lot of items inside:

  • BG_DISPLAY_MODES (background image's displaying mode.)
  • DECO_RELATIVETO (decoration's position's relativity.)
  • EASES (ease, such as linear and back-out.)
  • FILTERS (filters in filter action.)
  • HITSOUNDS (hitsounds for tiles.)
  • PLANES (plane for flash.)
  • RELATIVETO (camera's position's relativity.)
  • SPECIAL_ARTIST_TYPE (used on special situations you don't need to upload proof of permission from the artist.)
  • TILE_RANGE_TYPES (move track action's tile range's relativity.)
  • TRACK_APPEAR_ANIMATIONS (track appearing animation)
  • TRACK_DISAPPEAR_ANIMATIONS (track disappearing animation)
  • TRACK_COLOR_PULSE_TYPES (track color pulse type, such as forward, backward, none.)
  • TRACK_COLOR_TYPES (track color type, such as glow, switch, rainbow, etc.)
  • TRACK_STYLES (style of the track, such as gems, basic, neon, etc.)

These items are all Objects with string inside.

[Static] PathData

The instance of PathData class is a single path containing these two non-static properties:

  • absoluteAngle (angle relative to R tile. R tile has 180 absolute angle.)
  • code (the code of the tile. can be referred to {code} tile, such as R tile, U tile, ! tile and etc.)

The instance of the class can be created by doing new ADOFAI.PathData();.

When creating an instance of a class, the constructor takes two parameters:

  • val (code or absolute angle.)
  • settings (NOT EQUALVANT TO ADOFAI.Settings.)

The settings has 3 keys:

  • findNearestTileByAngle (default: false)
    • This finds the nearest angle existing in ADOFAI, and then create the tile.
  • useSmallerAngleOnOverlapping (default: false)
    • This decides whether to use the tile with a higher (<-- false) or smaller (<-- true) angle when the difference of nearest angle is both the same.
  • fallback (default: null, the value should be a path's code.)
    • This sets a fallback tile if you fail to generate a tile when you initiate the instance of the class.

[Static] Settings

Settings is an Object in the level. You need to copy the object here, and modify it and then overwrite the settings in other level instance.

A single settings object contains:

  • version
  • artist
  • specialArtistType
  • artistPermission
  • song
  • author
  • separateCountdownTime
  • previewImage
  • previewIcon
  • previewIconColor
  • previewSongStart
  • previewSongDuration
  • seizureWarning
  • levelDesc
  • levelTags
  • artistPermission
  • artistLinks
  • difficulty
  • songFilename
  • bpm
  • volume
  • offset
  • pitch
  • hitsound
  • hitsoundVolume
  • countdownTicks
  • trackColorType
  • trackColor
  • secondaryTrackColor
  • trackColorAnimDuration
  • trackColorPulse
  • trackPulseLength
  • trackStyle
  • trackAnimation
  • beatsAhead
  • trackDisappearAnimation
  • beatsBehind
  • backgroundColor
  • bgImage
  • bgImageColor
  • parallax
  • bgDisplayMode
  • lockRot
  • loopBG
  • unscaledSize
  • relativeTo
  • position
  • rotation
  • zoom
  • bgVideo
  • loopVideo
  • vidOffset
  • floorIconOutlines
  • stickToFloors
  • planetEase
  • planetEaseParts

[Static] Action

Action is a class of level's actions.

An action class is a superclass of every action in the game. You are most likely looking for a subclass that allows you to write and set custom values depending on the type of action.

You first need to create a default action, this will decide:

  • floor (int)
  • eventType (string, for list of every action name do Object.keys(ADOFAI.Action.ACTIONS_LIST);)
  • eventValue (subclass of ActionValue)

The type of event goes to eventType.

Here are all types of actions you can use.

  • AddDecoration
  • AnimateTrack
  • Bloom
  • Checkpoint
  • ColorTrack
  • CustomBackground
  • Flash
  • HallOfMirrors
  • MoveCamera
  • MoveDecorations
  • MoveTrack
  • PositionTrack
  • RecolorTrack
  • RepeatEvents
  • SetConditionalEvents
  • SetFilter
  • SetHitsound
  • SetPlanetRotation
  • SetSpeed
  • ShakeScreen
  • Twirl

For empty action value, you can use new ADOFAI.Action.EmptyActionValue();

Each action value includes asJsonPart() function.

This function will print themselves as a part of JSON.

Code representation would be:

/**
 * Picks random event
 * @param {Number} floor floor of the action
 */
function randomEvent(floor) {
  // get index of the random action so we can get the type of action in string too
  var index = Math.floor(Math.random() * ADOFAI.Action.ACTIONS_LIST.length);

  return new ADOFAI.Action(
    floor /* floor for the event */,
    Object.keys(ADOFAI.Action.ACTIONS_LIST)[index] /* name of the event */,
    ADOFAI.Action.ACTIONS_LIST[index] /* default value of the event */
  );
}

var level = new ADOFAI(); // create a level

for (var i = 0; i < 5; i++) {
  var action = randomEvent(
    Math.floor(Math.random() * (level.pathData.length - 1)) + 1
  ); // generate random index of the path, at least 1.

  level.actions.push(action); // push the action
}

[Static] Import()

Imports a level from a JSON-like string.

Usage: var level = ADOFAI.Import(str);