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.

61 lines
2.2 KiB

  1. /*******************************************************************************************
  2. *
  3. * raylib [text] example - Text formatting
  4. *
  5. * This example has been created using raylib 1.1 (www.raylib.com)
  6. * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
  7. *
  8. * Copyright (c) 2014 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 formatting");
  19. int score = 100020;
  20. int hiscore = 200450;
  21. int lives = 5;
  22. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  23. //--------------------------------------------------------------------------------------
  24. // Main game loop
  25. while (!WindowShouldClose()) // Detect window close button or ESC key
  26. {
  27. // Update
  28. //----------------------------------------------------------------------------------
  29. // TODO: Update your variables here
  30. //----------------------------------------------------------------------------------
  31. // Draw
  32. //----------------------------------------------------------------------------------
  33. BeginDrawing();
  34. ClearBackground(RAYWHITE);
  35. DrawText(FormatText("Score: %08i", score), 200, 80, 20, RED);
  36. DrawText(FormatText("HiScore: %08i", hiscore), 200, 120, 20, GREEN);
  37. DrawText(FormatText("Lives: %02i", lives), 200, 160, 40, BLUE);
  38. DrawText(FormatText("Elapsed Time: %02.02f ms", GetFrameTime()*1000), 200, 220, 20, BLACK);
  39. EndDrawing();
  40. //----------------------------------------------------------------------------------
  41. }
  42. // De-Initialization
  43. //--------------------------------------------------------------------------------------
  44. CloseWindow(); // Close window and OpenGL context
  45. //--------------------------------------------------------------------------------------
  46. return 0;
  47. }