that_one_nigga_you_k

entrada de numeros

May 7th, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <raylib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     vector<int> arr;
  10.  
  11.     SetTargetFPS(60);
  12.     InitWindow(1000, 600, "teste");
  13.  
  14.     int numero = 0;
  15.     int digit = 0;
  16.  
  17.     while (!WindowShouldClose()) {
  18.  
  19.        
  20.         if (IsKeyPressed(KEY_ENTER)) {
  21.             arr.push_back(numero);
  22.             numero = 0;
  23.         } else if (IsKeyDown(KEY_ZERO)) {
  24.            
  25.             arr.clear();
  26.         } else if (IsKeyPressed(KEY_BACKSPACE)) {
  27.            
  28.             if (numero > 0) {
  29.                 numero /= 10;
  30.             }
  31.         } else if (IsKeyDown(KEY_ONE) || IsKeyDown(KEY_TWO) || IsKeyDown(KEY_THREE) || IsKeyDown(KEY_FOUR) || IsKeyDown(KEY_FIVE) ||
  32.                    IsKeyDown(KEY_SIX) || IsKeyDown(KEY_SEVEN) || IsKeyDown(KEY_EIGHT) || IsKeyDown(KEY_NINE)) {
  33.            
  34.            
  35.             if (IsKeyDown(KEY_ONE)) digit = 1;
  36.             else if (IsKeyDown(KEY_TWO)) digit = 2;
  37.             else if (IsKeyDown(KEY_THREE)) digit = 3;
  38.             else if (IsKeyDown(KEY_FOUR)) digit = 4;
  39.             else if (IsKeyDown(KEY_FIVE)) digit = 5;
  40.             else if (IsKeyDown(KEY_SIX)) digit = 6;
  41.             else if (IsKeyDown(KEY_SEVEN)) digit = 7;
  42.             else if (IsKeyDown(KEY_EIGHT)) digit = 8;
  43.             else if (IsKeyDown(KEY_NINE)) digit = 9;
  44.  
  45.            
  46.             numero = numero * 10 + digit;
  47.             WaitTime(0.2);
  48.         }
  49.  
  50.        
  51.         int yOffset = 40;
  52.  
  53.         BeginDrawing();
  54.         ClearBackground(BLACK);
  55.  
  56.         // Exibe instruções na tela
  57.         DrawText("Digite um número (0 para ordenar): ", 10, 10, 20, WHITE);
  58.        
  59.        
  60.         for (size_t i = 0; i < arr.size(); ++i) {
  61.             DrawText(to_string(arr[i]).c_str(), 10, 10 + yOffset * (i + 1), 20, WHITE);
  62.         }
  63.        
  64.        
  65.         DrawText(to_string(numero).c_str(), 10, 10 + yOffset * (arr.size() + 1), 20, WHITE);
  66.  
  67.         EndDrawing();
  68.     }
  69.  
  70.     CloseWindow();
  71.  
  72.     return 0;
  73. }
  74.  
Add Comment
Please, Sign In to add comment