mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-21 05:45:39 +00:00
Modify text_words_alignment.c (#5411)
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#include "raymath.h" // Required for: Lerp()
|
#include "raymath.h" // Required for: Lerp()
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
typedef enum TextAlignment {
|
typedef enum TextAlignment {
|
||||||
TEXT_ALIGN_LEFT = 0,
|
TEXT_ALIGN_LEFT = 0,
|
||||||
TEXT_ALIGN_TOP = 0,
|
TEXT_ALIGN_TOP = 0,
|
||||||
@@ -58,7 +60,7 @@ int main(void)
|
|||||||
// And of course the font...
|
// And of course the font...
|
||||||
Font font = GetFontDefault();
|
Font font = GetFontDefault();
|
||||||
|
|
||||||
// Intialize the alignment variables
|
// Initialize the alignment variables
|
||||||
TextAlignment hAlign = TEXT_ALIGN_CENTRE;
|
TextAlignment hAlign = TEXT_ALIGN_CENTRE;
|
||||||
TextAlignment vAlign = TEXT_ALIGN_MIDDLE;
|
TextAlignment vAlign = TEXT_ALIGN_MIDDLE;
|
||||||
|
|
||||||
@@ -72,8 +74,7 @@ int main(void)
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_LEFT))
|
if (IsKeyPressed(KEY_LEFT))
|
||||||
{
|
{
|
||||||
hAlign = hAlign - 1;
|
if (hAlign > 0) hAlign = hAlign - 1;
|
||||||
if (hAlign < 0) hAlign = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_RIGHT))
|
if (IsKeyPressed(KEY_RIGHT))
|
||||||
@@ -84,8 +85,7 @@ int main(void)
|
|||||||
|
|
||||||
if (IsKeyPressed(KEY_UP))
|
if (IsKeyPressed(KEY_UP))
|
||||||
{
|
{
|
||||||
vAlign = vAlign - 1;
|
if (vAlign > 0) vAlign = vAlign - 1;
|
||||||
if (vAlign < 0) vAlign = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_DOWN))
|
if (IsKeyPressed(KEY_DOWN))
|
||||||
@@ -95,7 +95,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// One word per second
|
// One word per second
|
||||||
wordIndex = (int)GetTime()%wordCount;
|
if (wordCount > 0) wordIndex = (int)GetTime()%wordCount;
|
||||||
|
else wordIndex = 0;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@@ -132,4 +133,4 @@ int main(void)
|
|||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user