2016-02-11 12:26:45 +01:00
|
|
|
/*******************************************************************************************
|
|
|
|
|
*
|
2025-09-07 12:01:51 +02:00
|
|
|
* raylib [text] example - writing anim
|
2016-02-11 12:26:45 +01:00
|
|
|
*
|
2025-01-17 03:42:30 -06:00
|
|
|
* Example complexity rating: [★★☆☆] 2/4
|
|
|
|
|
*
|
2022-07-20 01:28:37 +02:00
|
|
|
* Example originally created with raylib 1.4, last time updated with raylib 1.4
|
2016-02-11 12:26:45 +01:00
|
|
|
*
|
2022-07-20 01:28:37 +02:00
|
|
|
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
|
|
|
|
* BSD-like license that allows static linking with closed source software
|
|
|
|
|
*
|
2025-01-18 10:41:56 -08:00
|
|
|
* Copyright (c) 2016-2025 Ramon Santamaria (@raysan5)
|
2016-02-11 12:26:45 +01:00
|
|
|
*
|
|
|
|
|
********************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "raylib.h"
|
|
|
|
|
|
2022-06-21 19:53:18 +02:00
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
|
// Program main entry point
|
|
|
|
|
//------------------------------------------------------------------------------------
|
2019-05-20 16:36:42 +02:00
|
|
|
int main(void)
|
2016-02-11 12:26:45 +01:00
|
|
|
{
|
|
|
|
|
// Initialization
|
|
|
|
|
//--------------------------------------------------------------------------------------
|
2019-05-20 16:36:42 +02:00
|
|
|
const int screenWidth = 800;
|
|
|
|
|
const int screenHeight = 450;
|
2016-02-11 12:26:45 +01:00
|
|
|
|
2025-09-07 12:01:51 +02:00
|
|
|
InitWindow(screenWidth, screenHeight, "raylib [text] example - writing anim");
|
2019-05-20 16:36:42 +02:00
|
|
|
|
2016-02-11 12:26:45 +01:00
|
|
|
const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)";
|
2019-05-20 16:36:42 +02:00
|
|
|
|
2016-02-11 12:26:45 +01:00
|
|
|
int framesCounter = 0;
|
2019-05-20 16:36:42 +02:00
|
|
|
|
|
|
|
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
2016-02-11 12:26:45 +01:00
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Main game loop
|
|
|
|
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
|
|
|
{
|
|
|
|
|
// Update
|
|
|
|
|
//----------------------------------------------------------------------------------
|
2016-11-06 10:06:18 +01:00
|
|
|
if (IsKeyDown(KEY_SPACE)) framesCounter += 8;
|
|
|
|
|
else framesCounter++;
|
2019-05-20 16:36:42 +02:00
|
|
|
|
2016-02-11 12:26:45 +01:00
|
|
|
if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// Draw
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
BeginDrawing();
|
|
|
|
|
|
|
|
|
|
ClearBackground(RAYWHITE);
|
|
|
|
|
|
2018-12-26 13:26:34 +01:00
|
|
|
DrawText(TextSubtext(message, 0, framesCounter/10), 210, 160, 20, MAROON);
|
2019-05-20 16:36:42 +02:00
|
|
|
|
2016-11-06 10:06:18 +01:00
|
|
|
DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, LIGHTGRAY);
|
2024-08-09 02:07:56 -05:00
|
|
|
DrawText("HOLD [SPACE] to SPEED UP!", 239, 300, 20, LIGHTGRAY);
|
2016-02-11 12:26:45 +01:00
|
|
|
|
|
|
|
|
EndDrawing();
|
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// De-Initialization
|
2019-05-20 16:36:42 +02:00
|
|
|
//--------------------------------------------------------------------------------------
|
2016-02-11 12:26:45 +01:00
|
|
|
CloseWindow(); // Close window and OpenGL context
|
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|