1/*******************************************************************************************
2*
3* raylib [text] example - Text Writing Animation
4*
5* This example has been created using raylib 2.3 (www.raylib.com)
6* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
7*
8* Copyright (c) 2016 Ramon Santamaria (@raysan5)
9*
10********************************************************************************************/
11
12#include "raylib.h"
13
14int main(void)
15{
16 // Initialization
17 //--------------------------------------------------------------------------------------
18 const int screenWidth = 800;
19 const int screenHeight = 450;
20
21 InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim");
22
23 const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)";
24
25 int framesCounter = 0;
26
27 SetTargetFPS(60); // Set our game to run at 60 frames-per-second
28 //--------------------------------------------------------------------------------------
29
30 // Main game loop
31 while (!WindowShouldClose()) // Detect window close button or ESC key
32 {
33 // Update
34 //----------------------------------------------------------------------------------
35 if (IsKeyDown(KEY_SPACE)) framesCounter += 8;
36 else framesCounter++;
37
38 if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
39 //----------------------------------------------------------------------------------
40
41 // Draw
42 //----------------------------------------------------------------------------------
43 BeginDrawing();
44
45 ClearBackground(RAYWHITE);
46
47 DrawText(TextSubtext(message, 0, framesCounter/10), 210, 160, 20, MAROON);
48
49 DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, LIGHTGRAY);
50 DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, LIGHTGRAY);
51
52 EndDrawing();
53 //----------------------------------------------------------------------------------
54 }
55
56 // De-Initialization
57 //--------------------------------------------------------------------------------------
58 CloseWindow(); // Close window and OpenGL context
59 //--------------------------------------------------------------------------------------
60
61 return 0;
62}