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.

53 lines
2.1 KiB

  1. -------------------------------------------------------------------------------------------
  2. --
  3. -- raylib [text] example - Text formatting
  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 formatting")
  16. local score = 100020
  17. local hiscore = 200450
  18. local lives = 5
  19. SetTargetFPS(60) -- Set target frames-per-second
  20. -------------------------------------------------------------------------------------------
  21. -- Main game loop
  22. while not WindowShouldClose() do -- Detect window close button or ESC key
  23. -- Update
  24. ---------------------------------------------------------------------------------------
  25. -- TODO: Update your variables here
  26. ---------------------------------------------------------------------------------------
  27. -- Draw
  28. ---------------------------------------------------------------------------------------
  29. BeginDrawing()
  30. ClearBackground(RAYWHITE)
  31. DrawText(string.format("Score: %08i", score), 200, 80, 20, RED)
  32. DrawText(string.format("HiScore: %08i", hiscore), 200, 120, 20, GREEN)
  33. DrawText(string.format("Lives: %02i", lives), 200, 160, 40, BLUE)
  34. DrawText(string.format("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK)
  35. EndDrawing()
  36. ---------------------------------------------------------------------------------------
  37. end
  38. -- De-Initialization
  39. -------------------------------------------------------------------------------------------
  40. CloseWindow() -- Close window and OpenGL context
  41. -------------------------------------------------------------------------------------------