Welcome to the style guidelines page! In this page, I will highlight the style guidelines that I (Sparen) use or plan to use in all tutorials on this website. These style guidelines are not official but it is recommended you follow them.
This is based off of Checkstyle (the Coding Style Standards for Java), and as such, I will organize this page in such a way as to show what is and is not acceptable.
//Not Acceptable
//Acceptable
let x;//declare x
let x; //declare x
It is also acceptable to use tabs, as long as you ONLY use tabs and do not use spaces for indentation at all. Tabs or spaces, not a mixture of both.
This is because tab sizes are not standardized. Always maintain a standard indent size for your own code.
sub a{
function();
}
sub a{
function();
}
let x = [1,2,3];
ObjSprite2D_SetSourceRect(objEnemy,64,1,127,64);
let x = [1, 2, 3];
ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64);
#include"file.dnh"
#include "file.dnh"
Affects + - % = += -= *= /= %= == != > < >= <= && || ~
The negation operator ! is excluded from this guideline.
The multiplication and division operators * and / are excluded from this guideline but it is still recommended that spaces be added except in cases when it hampers legibility. However, if spaces are used, spaces must be used on both sides.
let x=5+4;
let y=x>10;
x+=3/5;
if(x>=20&&!y){
let z = (x!=3)||y;
}
let str="danmaku"~"fu";
let x = 5 + 4;
let y = x > 10;
x += 3 / 5;
if(x >= 20 || !y){
let z = (x != 3) || y;
}
let str = "danmaku" ~ "fu";
let m = 3 /2;
let n = 3 /2;
let p = 1 + 3/ 2;
let q = 1 + 3 /2;
let m = 3/2;
let n = 3 / 2;
let p = 1 + 3 / 2;
let q = 1 + 3/2;
Functions are not to be confused with control statements such as if, else, ascent, while, etc.
Note: I add a space after function names in the documentation tooltips in order to make web browser word wrapping work nicely; however, I advise against this practice in Danmakufu ph3.
myfunc ();
myfunc();
loop(5){}
loop (5){}
We suggest not using white space after control statements.
Additionally, as stated in Lesson 6, there is no standard in Danmakufu for placing a { on the same line as the control statement or on the next line.
loop(5){}
loop(5) {}
loop(5){
}
loop (5)
{
}
function GetCenterX{
return 192;
}
GetCenterX;
function GetCenterX(){
return 192;
}
GetCenterX();
task CreateBullet(){
let obj = CreateShotA1(0, 0, 0, 0, 0, 0);
}
BulletCommands();
task CreateBullet{
let obj = CreateShotA1(0, 0, 0, 0, 0, 0);
}
BulletCommands;
function abc(){}
function CreateBulletStringA1(){}
task BulletCommands{}
task fire1{}
sub renderObject{}
However, we suggest capitalizing all words.
function GetCenterX(){}
task CreateParticleA1{}
sub RenderHitbox{}
let bl_small_magenta = 23;
let BL_SMALL_MAGENTA = 23;
let AngleToPlayer = GetAngleToPlayer(objBoss);
let Angletoplayer = GetAngleToPlayer(objBoss);
let angletoplayer = GetAngleToPlayer(objBoss);
let angleToPlayer = GetAngleToPlayer(objBoss);
let angle_to_player = GetAngleToPlayer(objBoss);
ascent(x in 0..5) {
ascent(y in -2..3) {
descent(z in BALL_MAGENTA.. BALL_AQUA) {
}
}
}
ascent(i in 0..5) {
ascent(j in -2..3) {
descent(k in BALL_MAGENTA.. BALL_AQUA) {
}
}
}
This is a convention where i, j, k, etc. are used for integers in counting loops. This convention does not need to be followed if known integer values are not being counted.
ascent(obj in 0..length(GetAllEnemyID())) {
Obj_Delete(obj);
}