(Modified from raylib's conventions)
In Vinora Project we use C99. We would use C89 (for a lot of reasons), but raylib use C99, so we kinda concede here.
Still, we have no respect for so called "technical standarts" here.
Compability is our sacred cow, especially backwards compatibility.
VLA: Just don't. Please.
AND USING VLA'S IS ACTIVELY STUPID!
-- Linus Torvalds
Non-ASCII characters in source code and file paths
Compatibility above everything.
You can use whatever you want on your machine, but we have no right to
expect that people have Unicode support for system paths and editors.
P.S. But users could use Unicode in Vinora Screenplay, since we
grant them this ability with Vinora Engine.
To be continiued...
It's mostly the same as raylib, except enum members.
If you're an old-school C developer, pls look carefully: this conventions
may be unusual for you.
| Code element | Convention | Example |
|---|---|---|
| Defines | ALL_CAPS | #define PLATFORM_DESKTOP |
| Macros | ALL_CAPS | #define MIN(a,b) (((a)<(b))?(a):(b)) |
| Variables | lowerCase | float targetFrameTime = 0.016f; |
| - local | lowerCase | Vector2 playerPosition = { 0 }; |
| - global | lowerCase | bool windowReady = false; |
| Constants | lowerCase | const int maxValue = 8; |
| Pointers | MyType *pointer | Texture2D *array = NULL; |
| Float values | always x.xf | float gravity = 10.0f |
| Operators | value1*value2 | int product = value*6; |
| Operators | value1/value2 | int division = value/4; |
| Operators | value1 + value2 | int sum = value + 10; |
| Operators | value1 - value2 | int res = value - 5; |
| Enum | TitleCase | enum TextureFormat |
| - members | snake_case | pixelformat_uncompressed_r8g8b8 |
| Struct | TitleCase | struct Texture2D, struct Material |
| - members | lowerCase | texture.width, color.r |
| Functions | TitleCase | InitWindow(), LoadImageFromMemory() |
| Parametrs | lowerCase | func(int screenWidth, int screenHeight) |
if (condition) value = 0;
while (!WindowShouldClose())
{
}
for (int i = 0; i < NUM_VALUES; i++) printf("%i", i);
// Be careful with the switch formatting!
switch (value)
{
case 'a':
// Some code
break;
case 'b':
// Also code.
break;
default: def(); break; // One-line
}
All conditions checks are always between parenthesis but not boolean values:
if ((value > 1) && (value < 50) && valueActive)
{
}
When dealing with braces or curly brackets, open-close them in aligned mode:
void SomeFunction()
{
// TODO: Do something here!
}
If proposing new functions, please try to use a clear naming for function-name and functions-parameters, in case of doubt, open an issue for discussion.
Directories will be named using snake_case:
resources/models, resources/fonts
Files will be named using snake_case:
main_title.png, cubicmap.png, sound.wav
NOTE: Avoid any spaces, special or non-ASCII characters in the files/dir naming!
Here is an example, note that some resources require to be loaded all at once whileother require to be loaded only at initialization (gui, font).
resources/audio/fx/long_jump.wav
resources/audio/music/main_theme.ogg
resources/screens/logo/logo.png
resources/screens/title/title.png
resources/screens/gameplay/background.png
resources/characters/player.png
resources/characters/enemy_slime.png
resources/common/font_arial.ttf
resources/common/gui.png
NOTE: all of this applies only for developing versions. In release version, all of file should be embedded in to binary.