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.

66 lines
2.5 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [text] example - Text formatting
  4. *
  5. * Example originally created with raylib 1.1, last time updated with raylib 3.0
  6. *
  7. * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
  8. * BSD-like license that allows static linking with closed source software
  9. *
  10. * Copyright (c) 2014-2024 Ramon Santamaria (@raysan5)
  11. *
  12. ********************************************************************************************/
  13. #include "raylib.h"
  14. //------------------------------------------------------------------------------------
  15. // Program main entry point
  16. //------------------------------------------------------------------------------------
  17. int main(void)
  18. {
  19. // Initialization
  20. //--------------------------------------------------------------------------------------
  21. const int screenWidth = 800;
  22. const int screenHeight = 450;
  23. InitWindow(screenWidth, screenHeight, "raylib [text] example - text formatting");
  24. int score = 100020;
  25. int hiscore = 200450;
  26. int lives = 5;
  27. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  28. //--------------------------------------------------------------------------------------
  29. // Main game loop
  30. while (!WindowShouldClose()) // Detect window close button or ESC key
  31. {
  32. // Update
  33. //----------------------------------------------------------------------------------
  34. // TODO: Update your variables here
  35. //----------------------------------------------------------------------------------
  36. // Draw
  37. //----------------------------------------------------------------------------------
  38. BeginDrawing();
  39. ClearBackground(RAYWHITE);
  40. DrawText(TextFormat("Score: %08i", score), 200, 80, 20, RED);
  41. DrawText(TextFormat("HiScore: %08i", hiscore), 200, 120, 20, GREEN);
  42. DrawText(TextFormat("Lives: %02i", lives), 200, 160, 40, BLUE);
  43. DrawText(TextFormat("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK);
  44. EndDrawing();
  45. //----------------------------------------------------------------------------------
  46. }
  47. // De-Initialization
  48. //--------------------------------------------------------------------------------------
  49. CloseWindow(); // Close window and OpenGL context
  50. //--------------------------------------------------------------------------------------
  51. return 0;
  52. }