Skip to content

Instantly share code, notes, and snippets.

@bluebear94
Last active May 12, 2018 08:16
Show Gist options
  • Save bluebear94/b366fb3b13ce6a922659 to your computer and use it in GitHub Desktop.
Save bluebear94/b366fb3b13ce6a922659 to your computer and use it in GitHub Desktop.
Fluffy8x / Uruwi's Danmakufu Coding Style

Inspired by Sparen's personal guidelines, though I have followed this style guide for quite a long time.

  • Use the extension .dnh for any Danmakufu files.
  • Encode sources in Shift-JIS only if there are no characters in the source outside ASCII. Otherwise, use UTF-16LE (the only other encoding supported by Danmakufu, unfortunately).
  • In single-line comments, leave one space before and after the //.
  • Start and end multi-line comments on lines that do not contain any code. Leave a space after /* and before */.
  • Leave a space between the #include directive and the file you wish to include.
  • Paths to files to #include should start with either . or ...
  • Use tabs for indentation.
  • Leave one space after a comma.
  • Leave one space on either side of a binary operator, including the .. in ascent and descent.
  • Do not space a function call from its parameters.
  • Do space a control statement from whatever comes after it.
  • Leave one space before an opening brace. Leave it on the same line as the control statement in question.
  • If a block consists of one statement, you may leave it with braces around, in one line. In this case, leave one space around the statement.
  • Parentheses are not required if a function or task has no parameters.
  • The recommended naming scheme for functions and tasks is camelCase. ObjSomething_PascalCase is okay for functions mimicking object functions. (Some of the code in my projects do break this guideline, as they were based on mkm's example scripts.)
  • As with functions, use camelCase for variables.
  • Use SCREAMING_SNAKE_CASE for constants.
  • If a function call spans multiple lines, it should rest alone, possibly with a trailing comma or semicolon, but if the result is assigned to the variable, the declaration should share its line with the call. The first line should end with an opening parenthesis, and the last line should end with a closing parenthesis, possibly with a trailing comma or semicolon. Each argument should rest on its own line, with a trailing comma, indented. (Exception: x/y, r/t, l/w can be on the same line.)
longFunctionName(
    argA,
    argB + argC
);
let a = anotherLongFunctionName(
    argA,
    argB + argC,
    argD - argE
);
let shot = CreateShotA1(
    x, y - 10,
    2, 90,
    DS_BALL_S_RED,
    30
);
@bluebear94
Copy link
Author

Probably one last rule: don't use Danmakufu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment