Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

61 linhas
2.3 KiB

  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. #include "raylib.h"
  12. int main(void)
  13. {
  14. // Initialization
  15. //--------------------------------------------------------------------------------------
  16. const int screenWidth = 800;
  17. const 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); // Set our game to run at 60 frames-per-second
  22. //--------------------------------------------------------------------------------------
  23. // Main game loop
  24. while (!WindowShouldClose()) // Detect window close button or ESC key
  25. {
  26. // Update
  27. //----------------------------------------------------------------------------------
  28. if (IsKeyDown(KEY_SPACE)) framesCounter += 8;
  29. else framesCounter++;
  30. if (IsKeyPressed(KEY_ENTER)) framesCounter = 0;
  31. //----------------------------------------------------------------------------------
  32. // Draw
  33. //----------------------------------------------------------------------------------
  34. BeginDrawing();
  35. ClearBackground(RAYWHITE);
  36. DrawText(TextSubtext(message, 0, framesCounter/10), 210, 160, 20, MAROON);
  37. DrawText("PRESS [ENTER] to RESTART!", 240, 260, 20, LIGHTGRAY);
  38. DrawText("PRESS [SPACE] to SPEED UP!", 239, 300, 20, LIGHTGRAY);
  39. EndDrawing();
  40. //----------------------------------------------------------------------------------
  41. }
  42. // De-Initialization
  43. //--------------------------------------------------------------------------------------
  44. CloseWindow(); // Close window and OpenGL context
  45. //--------------------------------------------------------------------------------------
  46. return 0;
  47. }