diff --git a/raylib-coding-conventions.md b/raylib-coding-conventions.md index ea9b439..5bceb45 100644 --- a/raylib-coding-conventions.md +++ b/raylib-coding-conventions.md @@ -8,8 +8,8 @@ Constants | lowerCase | `const int maxValue = 8` Struct | TitleCase | `struct Texture2D` Struct members |lowerCase | `texture.id` Enum | TitleCase | `TextureFormat` -Enum members | ALL_CAPS | `UNCOMPRESSED_R8G8B8` -Functions | TitleCase or prefixTitleCase | `InitWindow()` +Enum members | ALL_CAPS | `PIXELFORMAT_UNCOMPRESSED_R8G8B8` +Functions | TitleCase or prefixTitleCase | `InitWindow()`/`rlLoadTexture()` Variables | lowerCase | `screenWidth` Local variables | lowerCase | `playerPosition` Global variables | lowerCase | `fullscreen` @@ -21,13 +21,45 @@ Pointers | MyType *pointer | `Texture2D *array;` float values | always x.xf | `float value = 10.0f` Ternary Operator | (condition)? result1 : result2 | `printf("Value is 0: %s", (value == 0)? "yes" : "no");` -raylib code does not use TABS, use 4 spaces instead. +Some other conventions to follow: -When dealing with braces or curly brackets, open-close them in aligned mode, it's more visual for students: + - raylib code does not use TABS, use 4 spaces instead. + + - Control flow statements always are followed by a space: +```c +if (condition) value = 0; + +while (!WindowShouldClose()) +{ + +} + +for (int i = 0; i < NUM_VALUES; i++) printf("%i", i); + +switch (value) +{ + case 0: + { + + } break; + case 2: break; + default: break; +} +``` + - All conditions checks are always between parenthesis but not boolean values: +```c +if ((value > 1) && (value < 50) && valueActive)) +{ + +} +``` + + - When dealing with braces or curly brackets, open-close them in aligned mode, it's more visual for students: ```c void SomeFunction() { // TODO: Do something here! } ``` -When 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. + +**When 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.**