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.

51 lines
2.0 KiB

  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [text] example - Text Writing Animation
  4. --
  5. -- This example has been created using raylib 1.6 (www.raylib.com)
  6. -- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. --
  8. -- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5)
  9. --
  10. -------------------------------------------------------------------------------------------
  11. -- Initialization
  12. -------------------------------------------------------------------------------------------
  13. local screenWidth = 800
  14. local screenHeight = 450
  15. InitWindow(screenWidth, screenHeight, "raylib [text] example - text writing anim")
  16. local message = "This sample illustrates a text writing\nanimation effect! Check it out! )"
  17. local framesCounter = 0
  18. SetTargetFPS(60) -- Set target frames-per-second
  19. -------------------------------------------------------------------------------------------
  20. -- Main game loop
  21. while not WindowShouldClose() do -- Detect window close button or ESC key
  22. -- Update
  23. ---------------------------------------------------------------------------------------
  24. framesCounter = framesCounter + 1
  25. if (IsKeyPressed(KEY.ENTER)) then framesCounter = 0 end
  26. ---------------------------------------------------------------------------------------
  27. -- Draw
  28. ---------------------------------------------------------------------------------------
  29. BeginDrawing()
  30. ClearBackground(RAYWHITE)
  31. DrawText(string.sub(message, 0, framesCounter//10), 210, 160, 20, MAROON)
  32. DrawText("PRESS [ENTER] to RESTART!", 240, 280, 20, LIGHTGRAY)
  33. EndDrawing()
  34. ---------------------------------------------------------------------------------------
  35. end
  36. -- De-Initialization
  37. -------------------------------------------------------------------------------------------
  38. CloseWindow() -- Close window and OpenGL context
  39. -------------------------------------------------------------------------------------------