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
..
inascent
anddescent
. - 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
);
Probably one last rule: don't use Danmakufu.