Maidens of the Kaleidoscope
LunarCast [Home] [Replays] [Netplay] [Files] [Settings]
Maidens of the Kaleidoscope [Forum] [Forum Archive]
Gensokyo Archive [Gallery] [Replays] [Patches]

Danmakufu ph3 Documentation / Wiki

A comprehensive manual and wiki to Danmakufu ph3


Math

Mathematical operations, frequently used in generating dynamic patterns

  • min(int a, int b)
    Returns the lesser of the two values
  • max(int a, int b)
    Returns the greater of the two values
  • log(int val)
    Returns the natural (base e) logarithm of the value.
  • log10(int val)
    Returns the common (base 10) logarithm of the value.
  • cos(int val)
    Returns the cosine of the angle. Cosine is a value between -1 and 1 that corresponds to the x-value in a coordinate plane.
  • sin(int val)
    Returns the sine of the angle. Sine is a value between -1 and 1 that corresponds to the y-value in a coordinate plane.
  • tan(int val)
    Returns the tangent of the angle. Tangent is the slope of the line created by the angle (x/y).
  • acos(int val)
    Returns the arccosine of the angle. acos(cos(x)) = x, if x is between 0 and 180.
  • asin(int val)
    Returns the arcsine of the value. asin(sin(x)) = x, if x is between -90 and 90.
  • atan(int val)
    Returns the arctangent of the value. atan(tan(x)) = x, if x is between -90 and 90.
  • atan2(int y, int x)
    Returns the arctangent of y/x, which is the angle from (0, 0) to (x, y).
    The angle will be in the range -180 < a <= 180, where a is the returned value. Useful for getting the angle from one point to another point. For example, the angle from the boss to the player is atan2(player y - boss y, player x - boss x).
  • rand(min, max)
    Returns a random value between the two values. Note that the random value is not an integer; if you need one, use either round(), ceil(), or floor() on the returned value.
  • round(int val)
    Returns the value as an integer. Values of 0.5 or greater are rounded up; otherwise they are rounded down.
  • truncate(int val)
    Returns the value with no decimal places. For instance, 1.123 becomes 1. The shortened name trunc can also be used to refer to this function.
  • ceil(int val)
    Returns the value rounded up to the next integer.
  • floor(int val)
    Returns the value rounded down to the next integer.
  • absolute(int val)
    Returns the value as an absolute number (if it is negative, it will be changed to a positive).
  • modc(value, divider)
    Returns a modulus of the first value. Modulus provides the remainder of the division (7 modulo 5 would be 2).
    Note: unlike remainder, modc returns a value with the same sign as the dividend: modc(-7, 4) equals -3 and modc(7, -4) equals 3.
  • round(int val)
    Returns the value as an integer. Values of 0.5 or greater are rounded up; otherwise they are rounded down.
  • pi()
    Returns the value of pi.

Text Functions

Loading fonts, converting integers to strings etc.

  • LoadFont(char[] path)
    Loads the given font, which can be used with ObjText_SetFontType, allowing for usage of fonts that are not standard to Windows. Returns true if successful.
    Note, anything other than a Shift-JIS font will not be displayed properly if Danmakufu is run with AppLocale (before ph3 [.1 pre2]).
  • ToString(int value)
    Returns the value as a string, able to be used by text functions. (Text functions cannot normally read numbers.)
  • IntToString(int value)
    Returns the value as a string, omits any decimal places.
  • itoa(int value)
    Converts an integer value to a string, but leaves out decimal places. (This function might behave identically to IntToString.)
  • rtoa(int value)
    Converts any real number to a string.
  • rtos(char[] format, int value)
    Returns the value as a string, with some filtering options. The format is presented as a string that determines how many digits will be shown; it can contain any combination of the following three characters: "0", ".", "#". "0" is a slot for a digit. "." represents the decimal place in the string. "#" creates a space in the string.
    For example, rtos("000.000", 1.23) = "001.230", and rtos("#00", 1.23) = " 01".
  • vtos(char[] format, int value)
    Returns the value as a string, with some more filtering options.
    Format:
    • "-" right-justified
    • "0" outputs 0 at unused places
    • "d" integer
    • "f" real
    • "s" string
    The format string is different from rtos in that it's more of a code than directly defining the digits that will be shown. First, the number of digits on each side of the decimal are specified (000.00 is 3.2 in the format string). Unused digits will be filled with spaces. If preceded by a "-", the digits will be right-justified, adding blank spaces to the right instead of the left. If preceded by a "0", all digits not occupied by the value will be filled by zeroes. If ended with a "d", the value will be presented as an integer. If ended with an "f", the value will be presented as a real number. If ended with an "s", this indicates the value given was in the form of a string.

    For example, vtos("03d", 1.23) = "001", vtos("3d", 1.23) = " 1", vtos("-3d", 1.23) = "1 ", and vtos("03.5f", 1.23) = "001.23000"
  • atoi(char[] string)
    Converts a string to an integer. If there is a decimal part, then it will be truncated. If the string does not represent a valid number, then 0 will be returned.
  • ator(char[] string)
    Converts a string to a real number. If the string does not represent a valid number, then 0 will be returned.
  • TrimString(char[] string)
    Returns the string with spaces removed from the beginning and ending of the text. For example, TrimString(" ABC ") will return "ABC".
  • SplitString(char[] string, char[] delimiter)
    Returns an array containing the split strings. For example, SplitString("A/123/BCD", "/") will return ["A", "123", "BCD"].

Path Functions

Loading files, interfacing with the file system etc.

Time

Date/Time, Stage Time and FPS readings

  • GetCurrentDateTimeS
    Returns a string containing the current date and time. For example, if the current date is 2012/09/16 12:34:56, then "20120916123456" will be returned. If you wanted to convert it to a number, you may use the atoi function; for example, let year = atoi(GetCurrentDateTimeS[0..4]);
  • GetStageTime
    Returns a number with the amount of time that has been elapsed since the start of the main script. The value is in milliseconds.
  • GetPackageTime
    Returns a number with the amount of time that has been elapsed since the start of the package script. The value is in milliseconds.
  • GetCurrentFps
    Returns the current FPS.
  • GetReplayFps
    Returns the FPS of the replay at the current time. Note that this value refreshes as a much slower rate than GetCurrentFps.

Debug

Printing debug messages, assertions and error handling

Common Data

Share data between scripts

Audio

Play sound effects and music

Input

Get Keyboard and Mouse input


Key States

Key State Description Key State Description
KEY_FREE While the key is up KEY_PUSH The frame the key is pressed
KEY_HOLD While the key is held down KEY_PULL The frame the key is released

Virtual Key List

Key Constant Description Key Constant Description
VK_LEFT Move Left VK_RIGHT Move Right
VK_UP Move Up VK_Down Move Down
VK_SHOT Shot VK_BOMB Bomb / Spell Card
VK_SLOWMOVE Focus / Slow movement VK_USER1 User Key 1
VK_USER2 User Key 2 VK_OK Accept
VK_CANCEL Cancel VK_PAUSE Pause

Key List

Key Constant Keyboard Key Key Constant Keyboard Key
KEY_0 ... KEY_9 0-9 Keys KEY_A ... KEY_Z A-Z Keys
KEY_F1 ... KEY_F10 Function Keys KEY_MINUS - Key
KEY_EQUALS = KEY_SLASH /
KEY_BACK Backspace KEY_TAB Tab
KEY_SPACE Space KEY_LBRACKET [
KEY_RBRACKET ] KEY_SEMICOLON :
KEY_APOSTROPHE ' KEY_GRAVE `
KEY_BACKSLASH \ KEY_YEN \
KEY_AT @ KEY_COLON :
KEY_UNDERLINE _ KEY_CIRCUMFLEX ^
KEY_COMMA , KEY_PERIOD .
KEY_INSERT Insert KEY_DELETE Delete
KEY_RETURN Return / Enter KEY_LCONTROL Left Control
KEY_RCONTROL Right Control KEY_LSHIFT Left Shift
KEY_RSHIFT Right Shift KEY_LEFT Left Arrow
KEY_RIGHT Right Arrow KEY_UP Up Arrow
KEY_DOWN Down Arrow KEY_NUMPAD0 ... KEY_NUMPAD9 Number Pad
KEY_ADD Number Pad + KEY_SUBTRACT Number Pad -
KEY_MULTIPLY Number Pad * KEY_DIVIDE Number Pad /
KEY_DECIMAL Number Pad . KEY_NUMPADEQUALS Number Pad =
  • GetVirtualKeyState(enum KeyCode key)
    Returns the state of the specified virtual key.
    Refer to this list of Virtual Keys and Key States.
  • SetVirtualKeyState(enum KeyCode key, enum KeyState keyState)
    Temporarily sets the given virtual key to the given state.
    The virtual key will be restored to its true state a frame after you stop calling this function.
    Keep in mind that if you set it to KEY_HOLD it will not go to KEY_PULL or KEY_PUSH.
    Refer to this list of Virtual Keys and Key States.
  • AddVirtualKey(enum KeyCode virtualKeyName, enum KeyCode keyName, enum KeyCode gamepadKey)
    Registers the given virtual key with the given key.
    You may map any number of virtual keys to a single key, but virtual keys may only be mapped to a single key.
    For an example, if you were to use AddVirtualKey(VK_SHOT, KEY_UP, KEY_INVALID);, whenever you press the up arrow key, the virtual shot key will be pressed.
    Take note that you will not be able to move up. To fix this, you add AddVirtualKey(VK_UP, KEY_UP, KEY_INVALID);. You will now shoot and move up at the same time.
    However, if you were to add AddVirtualKey(VK_UP, KEY_LEFT, KEY_INVALID); with the above two examples, you will not move up when you press up, because VK_UP has been remapped to KEY_LEFT.
    Refer to this list of Virtual Keys and Key States.
  • AddReplayTargetVirtualKey(enum KeyCode key)
    Registers the given key id to the replay file.
    This key id should be one that you have already registered with AddVirtualKey.
    Refer to this list of Virtual Keys and Key States.
  • GetKeyState(enum KeyCode key)
    Returns the given key id's current state.
    Refer to this list of Virtual Keys and Key States.
  • GetMouseState(enum KeyCode mouseButton)
    • MOUSE_LEFT - Left Mouse Button
    • MOUSE_MIDDLE - Middle Mouse Button
    • MOUSE_RIGHT - RightMouse Button
    Returns the given mouse button's current state.
    Refer to this list of Virtual Keys and Key States.
  • GetMouseX()
    Returns the mouse's X coordinate. The origin for the mouse coordinates is the upper left of the Danmakufu window (0, 0).
    Mouse coordinates will be properly adjusted according to the resizing of Danmakufu's window.
  • GetMouseY()
    Returns the mouse's Y coordinate. The origin for the mouse coordinates is the upper left of the Danmakufu window (0, 0).
    Mouse coordinates will be properly adjusted according to the resizing of Danmakufu's window.
  • GetMouseMoveZ()
    Returns the amount of change that has occurred to the mouse's Z axis.
    The Z axis is normally the middle mouse wheel. If there is no mouse wheel, the value will be 0.
    The value returned will be negative if the wheel was moved back, and positive if the wheel moved forward.
  • SetSkipModeKey()
    Specifies the key to use for fast playback mode. (Specify KEY_INVALID if you do not wish to enable fast playback)
    The default key is KEY_LCONTROL.

Render

Load textures manually, set Render Priority, render to Textures (snapshots), pixel shaders etc.

3D Camera

Adjust the 3D background camera

2D Camera

Adjust the 2D camera

Script

Load, Start and Close scripts

System

Manipulate score, graze and points, adjust render priorities and the STG frame parameters

Player

Adjust the player character

Enemy

Adjust enemies

    GetEnemyBossSceneObjectID
    Returns the boss scene object ID. When not in a boss scene, returns ID_INVALID.
  • GetEnemyBossObjectID
    Returns an array with the ID of the boss present on the screen in an array
  • GetAllEnemyID
    Returns an array with the ID of every enemy present on the screen
  • GetIntersectionRegistedEnemyID
    Returns an array with the Object ID of all enemies with a registered hitbox to player shots (via ObjEnemy_SetIntersectionCircleToShot()).
  • GetAllEnemyIntersectionPosition
    Returns a 2D array with the position of all enemies for which collision detection is true (currently intersecting) ([index][<x-coordinate, y-coordinate>]).
  • GetEnemyIntersectionPosition(double x, double y, double highestAcquisitionValue)
    Returns a 2D array with the enemy intersection position around given position ([index][<x-coordinate, y-coordinate>]).
    The first value (index 0) corresponds to the nearest position.
  • GetEnemyIntersectionPositionByIdA1(int objIdEnemy)
    Returns a 2D array with all collision detection positions of the specified enemy ([index][<x-coordinate, y-coordinate>]).
    The first value (index 0) corresponds to the nearest position from the enemy (unsure).
  • GetEnemyIntersectionPositionByIdA2(int objEnemyId, double x, double y)
    Returns a 2D array with all collision detection positions of the specified enemy ([index][<x-coordinate, y-coordinate>]).
    The first value (index 0) corresponds to the nearest position from the specified position.
  • LoadEnemyShotData(char[] path)
    Loads specified shot image file.
    Files with the same name can only be loaded once.
    Missing explanation about calling the function several times (?)
  • ReloadEnemyShotData(char[] path)
    Reloads specified shot image file (you can also (re)load a file that has not been loaded by LoadEnemyShotData).
    Unlike LoadEnemyShotData, this function can load the same file several times.
    Missing explanation about calling the function several times (?)

Shot

Create bullets, lasers or clear them from the screen among other things

Item

Create and collect pick up items

  • CreateItemA1(enum ItemTypes type, double x, double y, int score)
    Type:
    • ITEM_1UP(_S) - Extend
    • ITEM_SPELL(_S) - Spell
    • ITEM_POINT(_S) - Point
    • ITEM_POWER(_S) - Power
    • ITEM_USER - User-defined (add item constant to get desired item)
    Creates an item at the specified points. The optional "_S" suffix will create a smaller version of the specified item.
    "score" is the value the spawned item will add to your score.
  • CreateItemA2(enum ItemTypes type, double x, double y, double xDest, double yDest, int score)
    Type:
    • ITEM_1UP(_S) - Extend
    • ITEM_SPELL(_S) - Spell
    • ITEM_POINT(_S) - Point
    • ITEM_POWER(_S) - Power
    • ITEM_USER - User-defined (add item constant to get desired item)
    Same as CreateItemA1, except now it will quickly move towards the specified coordinates (xDest, yDest) before slowly falling down. The optional "_S" suffix will create a smaller version of the specified item.
    "score" is the value the spawned item will add to your score.
  • CreateItemU1(int userItemIdx, double x, double y, int score)
    Creates an item much like CreateItemA1, however it will spawn a user-defined item associated with the specified ID. (Effectively automatically prefixes your item index with ITEM_USER)
    "score" is the value the spawned item will add to your score.
  • CreateItemU2(int userItemIdx, double x, double y, double xDest, double yDest, int score)
    Same as CreateItemU1, except now it will quickly move towards the specified coordinates (xDest, yDest) before slowly falling down. (Effectively automatically prefixes your item index with ITEM_USER)
    "score" is the value the spawned item will add to your score.
  • CollectAllItems()
    Makes all items fly towards the player.
  • CollectItemsByType(enum ItemTypes type)
    Type:
    • ITEM_1UP(_S) - Extend
    • ITEM_SPELL(_S) - Spell
    • ITEM_POINT(_S) - Point
    • ITEM_POWER(_S) - Power
    • ITEM_USER - User-defined (add item constant to get desired item)
    Makes all items of the specified type fly toward the player.
  • CancelCollectItems()
    Cancels any items that were currently moving to the player for collection. This only appears to work for items collected by the player auto item collection line (SetPlayerAutoItemCollectLine).
  • StartItemScript(char[] path)
    Starts the script for processing user-defined items.
  • SetDefaultBonusItemEnable(bool isEnabled)
    Sets whether or not to create the default autocollected bullet delete items when bullets are deleted to items. True will create the items, false will not. The default value is true.
  • LoadItemData(char[] path)
    Loads the specified item data. Can be called any amount of times, but currently existing IDs will be replaced by new ones of the same value. You may not use the same file twice in this function; to do so, see ReloadItemData.
  • ReloadItemData(char[] path)
    Reloads the specified item data. Can be called any amount of times, but currently existing IDs will be replaced by new ones of the same value. You do not need to use LoadItemData before using this function.

Other

Misc functions (Time Slow, Line-Circle and Object-Object collision tests, 2D position etc.)

Object

Base object functions all objects support

  • Obj_Delete(int objId)
    Deletes specified object.
  • Obj_IsDeleted(int objId)
    Returns true if the specified object has been deleted.
  • Obj_SetVisible(int objId, bool visibility)
    Sets visibility of specified object.
    If visibility is set to false, the object will not be drawn.
  • Obj_IsVisible(int objId)
    Returns true if the specified object is visible.
  • Obj_SetRenderPriority(int objId, real renderPriority)
    Sets the object's render priority as a ratio (0.0-1.0).
  • Obj_SetRenderPriorityI(int objId, int renderPriority)
    Sets the object's render priority in the range 0-100 (integer).
  • Obj_GetRenderPriority(int objId)
    Returns the object's render priority as a ratio (0.0-1.0).
  • Obj_SetRenderPriorityI(int objId)
    Returns the object's render priority as an integer (0-100).
  • Obj_GetValue(int objId, char[] key)
    Returns the value associated with the given key for the given object, previously set by Obj_SetValue.
    Warning: If the key-value pair does not exist or was deleted, attempting to access it will crash the program.
  • Obj_GetValueD(int objId, char[] key, var value)
    Returns the value associated with the given key for the given object, previously set by Obj_SetValue.
    If the key-value pair doesn't exist, the default value is returned instead.
  • Obj_SetValue(int objId, char[] key, var value)
    For the given object, maps the given key to the given value.
    The value can be returned by using Obj_GetValue with the corresponding key.
  • Obj_DeleteValue(int objId, char[] key)
    Deletes the key-value pair previously set by Obj_SetValue.
  • Obj_IsValueExists(int objId, char[] key)
    Returns true if the object has a key-value pair for the given key.
  • Obj_GetType(int objId)
    • OBJ_PRIMITIVE_2D - 2D Primitive
    • OBJ_SPRITE_2D - 2D Sprite (Usable with ObjSprite2D_ functions)
    • OBJ_SPRITE_LIST_2D - 2D Sprite List (Usable with ObjSpriteList2D_ functions)
    • OBJ_PRIMITIVE_3D - 3D Primitive
    • OBJ_SPRITE_3D - 3D Sprite (Usable with ObjSprite3D_ functions)
    • OBJ_MESH - 3D Mesh (Usable with ObjMesh_ functions)
    • OBJ_TEXT - Text Object (Usable with ObjText_ functions)
    • OBJ_SOUND - Sound Object (Usable with ObjSound_ functions)
    • OBJ_FILE_TEXT - Text File Object (Usable with ObjFileT_ functions)
    • OBJ_FILE_BINARY - Binary File Object (Usable with ObjFileB_ functions)
    • OBJ_PLAYER - Player (Usable with ObjPlayer_ functions)
    • OBJ_SPELL - Spell (Usable with ObjSpell_ functions)
    • OBJ_ENEMY - Enemy (Usable with ObjEnemy_ functions)
    • OBJ_ENEMY_BOSS_SCENE - Enemy Boss Scene (Usable with ObjEnemyBossScene_ functions)
    • OBJ_SHOT - Bullet (Usable with ObjShot_ functions)
    • OBJ_LOOSE_LASER - Free laser (Usable with ObjLaser_ functions)
    • OBJ_STRAIGHT_LASE - Long laser(Usable with ObjStLaser_ functions)
    • OBJ_CURVE_LASER - Curved laser (Usable with ObjLaser_ functions)
    • OBJ_ITEM - Item pickup (Usable with ObjItem_ functions)

Return to Home