Beginners_-_Drawtext_integers.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "raylib.h"
  2. int main(void)
  3. {
  4. // Initialization
  5. //--------------------------------------------------------------------------------------
  6. const int screenWidth = 800;
  7. const int screenHeight = 450;
  8. InitWindow(screenWidth, screenHeight, "raylib example.");
  9. int myvar = 0; // My thing here
  10. int myvar2 = 1; // My second var
  11. int myvar3 = 5;
  12. SetTargetFPS(60); // Set our game to run at 60 frames-per-second
  13. //--------------------------------------------------------------------------------------
  14. // Main game loop
  15. while (!WindowShouldClose()) // Detect window close button or ESC key
  16. {
  17. // Update
  18. //----------------------------------------------------------------------------------
  19. // TODO: Update your variables here
  20. //----------------------------------------------------------------------------------
  21. // Draw
  22. //----------------------------------------------------------------------------------
  23. BeginDrawing();
  24. ClearBackground(RAYWHITE);
  25. DrawText(FormatText("my var value : %01i" , myvar), 190, 200, 20, LIGHTGRAY);
  26. DrawText(FormatText("my var2 value : %05i" , myvar2), 190, 220, 20, LIGHTGRAY); // Here I changed it so it draws 5 numbers.
  27. DrawText(FormatText("my var2 + var3 value : %05i" , myvar2+myvar3), 190, 240, 20, LIGHTGRAY); // Here I changed it does some math.
  28. DrawText(FormatText("my var2 + var 3 + 1 value : %05i" , myvar2+myvar3+1), 190, 260, 20, LIGHTGRAY); // Here I changed it does some math.
  29. EndDrawing();
  30. //----------------------------------------------------------------------------------
  31. }
  32. // De-Initialization
  33. //--------------------------------------------------------------------------------------
  34. CloseWindow(); // Close window and OpenGL context
  35. //--------------------------------------------------------------------------------------
  36. return 0;
  37. }