Review variables initialization

This commit is contained in:
Ray
2019-05-27 00:18:15 +02:00
parent 241c4c8d14
commit 87774a0a21
33 changed files with 52 additions and 56 deletions

View File

@ -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

View File

@ -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++)
{

View File

@ -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
//----------------------------------------------------------------------------------

View File

@ -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
//--------------------------------------------------------------------------------------

View File

@ -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);