You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.1 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [text] example - Text Writing Animation
  4. *
  5. * This example has been created using raylib 1.4 (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. #include "raylib.h"
  12. int main()
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. int screenWidth = 800;
  17. int screenHeight = 450;
  18. InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim");
  19. const char message[128] = "This sample illustrates a text writing\nanimation effect! Check it out! ;)";
  20. int framesCounter = 0;
  21. SetTargetFPS(60);
  22. //--------------------------------------------------------------------------------------
  23. // Main game loop
  24. while (!WindowShouldClose()) // Detect window close button or ESC key
  25. {
  26. // Update
  27. //----------------------------------------------------------------------------------
  28. framesCounter++;
  29. if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
  30. //----------------------------------------------------------------------------------
  31. // Draw
  32. //----------------------------------------------------------------------------------
  33. BeginDrawing();
  34. ClearBackground(RAYWHITE);
  35. DrawText(SubText(message, 0, framesCounter/10), 210, 160, 20, MAROON);
  36. DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY);
  37. EndDrawing();
  38. //----------------------------------------------------------------------------------
  39. }
  40. // De-Initialization
  41. //--------------------------------------------------------------------------------------
  42. CloseWindow(); // Close window and OpenGL context
  43. //--------------------------------------------------------------------------------------
  44. return 0;
  45. }