diff options
| author | Ray <[email protected]> | 2019-05-27 00:18:15 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2019-05-27 00:18:15 +0200 |
| commit | 87774a0a21f8d2998b4dc13e989005270476ae92 (patch) | |
| tree | 4228376c752b1760be44cc8582725ecac522939b /examples/text | |
| parent | 241c4c8d14225bdf30c168802d4b16b59d5043e0 (diff) | |
| download | raylib-87774a0a21f8d2998b4dc13e989005270476ae92.tar.gz raylib-87774a0a21f8d2998b4dc13e989005270476ae92.zip | |
Review variables initialization
Diffstat (limited to 'examples/text')
| -rw-r--r-- | examples/text/text_font_sdf.c | 2 | ||||
| -rw-r--r-- | examples/text/text_raylib_fonts.c | 4 | ||||
| -rw-r--r-- | examples/text/text_rectangle_bounds.c | 12 | ||||
| -rw-r--r-- | examples/text/text_sprite_fonts.c | 14 | ||||
| -rw-r--r-- | examples/text/text_ttf_loading.c | 2 |
5 files changed, 16 insertions, 18 deletions
diff --git a/examples/text/text_font_sdf.c b/examples/text/text_font_sdf.c index d3c76c4f..91e43f75 100644 --- a/examples/text/text_font_sdf.c +++ b/examples/text/text_font_sdf.c @@ -57,7 +57,7 @@ int main(void) SetTextureFilter(fontSDF.texture, FILTER_BILINEAR); // Required for SDF font Vector2 fontPosition = { 40, screenHeight/2 - 50 }; - Vector2 textSize = { 0.0f }; + Vector2 textSize = { 0.0f, 0.0f }; float fontSize = 16.0f; int currentFont = 0; // 0 - fontDefault, 1 - fontSDF diff --git a/examples/text/text_raylib_fonts.c b/examples/text/text_raylib_fonts.c index 06e63725..d7e41a78 100644 --- a/examples/text/text_raylib_fonts.c +++ b/examples/text/text_raylib_fonts.c @@ -26,7 +26,7 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [text] example - raylib fonts"); // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required) - Font fonts[MAX_FONTS]; + Font fonts[MAX_FONTS] = { 0 }; fonts[0] = LoadFont("resources/fonts/alagard.png"); fonts[1] = LoadFont("resources/fonts/pixelplay.png"); @@ -48,7 +48,7 @@ int main(void) const int spacings[MAX_FONTS] = { 2, 4, 8, 4, 3, 4, 4, 1 }; - Vector2 positions[MAX_FONTS]; + Vector2 positions[MAX_FONTS] = { 0 }; for (int i = 0; i < MAX_FONTS; i++) { diff --git a/examples/text/text_rectangle_bounds.c b/examples/text/text_rectangle_bounds.c index 5871278f..abfb142b 100644 --- a/examples/text/text_rectangle_bounds.c +++ b/examples/text/text_rectangle_bounds.c @@ -22,7 +22,7 @@ int main(void) InitWindow(screenWidth, screenHeight, "raylib [text] example - draw text inside a rectangle"); - char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\ + const char text[] = "Text cannot escape\tthis container\t...word wrap also works when active so here's\ a long text for testing.\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\ tempor incididunt ut labore et dolore magna aliqua. Nec ullamcorper sit amet risus nullam eget felis eget."; @@ -38,15 +38,15 @@ int main(void) const int maxWidth = screenWidth - 50; const int maxHeight = screenHeight - 160; - Vector2 lastMouse = { 0, 0 }; // Stores last mouse coordinates - Color borderColor = MAROON; // Container border color - Font font = GetFontDefault(); // Get default system font + Vector2 lastMouse = { 0.0f, 0.0f }; // Stores last mouse coordinates + Color borderColor = MAROON; // Container border color + Font font = GetFontDefault(); // Get default system font - SetTargetFPS(60); // Set our game to run at 60 frames-per-second + SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- // Main game loop - while (!WindowShouldClose()) // Detect window close button or ESC key + while (!WindowShouldClose()) // Detect window close button or ESC key { // Update //---------------------------------------------------------------------------------- diff --git a/examples/text/text_sprite_fonts.c b/examples/text/text_sprite_fonts.c index 30028937..b7c9ab10 100644 --- a/examples/text/text_sprite_fonts.c +++ b/examples/text/text_sprite_fonts.c @@ -29,16 +29,14 @@ int main(void) Font font2 = LoadFont("resources/custom_alagard.png"); // Font loading Font font3 = LoadFont("resources/custom_jupiter_crash.png"); // Font loading - Vector2 fontPosition1, fontPosition2, fontPosition3; + Vector2 fontPosition1 = { screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2, + screenHeight/2 - font1.baseSize/2 - 80 }; - fontPosition1.x = screenWidth/2 - MeasureTextEx(font1, msg1, font1.baseSize, -3).x/2; - fontPosition1.y = screenHeight/2 - font1.baseSize/2 - 80; + Vector2 fontPosition2 = { screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2, + screenHeight/2 - font2.baseSize/2 - 10 }; - fontPosition2.x = screenWidth/2 - MeasureTextEx(font2, msg2, font2.baseSize, -2).x/2; - fontPosition2.y = screenHeight/2 - font2.baseSize/2 - 10; - - fontPosition3.x = screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2; - fontPosition3.y = screenHeight/2 - font3.baseSize/2 + 50; + Vector2 fontPosition3 = { screenWidth/2 - MeasureTextEx(font3, msg3, font3.baseSize, 2).x/2, + screenHeight/2 - font3.baseSize/2 + 50 }; SetTargetFPS(60); // Set our game to run at 60 frames-per-second //-------------------------------------------------------------------------------------- diff --git a/examples/text/text_ttf_loading.c b/examples/text/text_ttf_loading.c index cc59417d..b256bd1d 100644 --- a/examples/text/text_ttf_loading.c +++ b/examples/text/text_ttf_loading.c @@ -33,7 +33,7 @@ int main(void) float fontSize = font.baseSize; Vector2 fontPosition = { 40, screenHeight/2 - 80 }; - Vector2 textSize; + Vector2 textSize = { 0.0f, 0.0f }; // Setup texture scaling filter SetTextureFilter(font.texture, FILTER_POINT); |
