Advertisement
sebasvp2005

Untitled

Jun 5th, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.26 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include "enemigo.h"
  4. #include <conio.h>
  5. using namespace std;
  6. using namespace System;
  7.  
  8.  
  9. int x = 30;
  10. int tim = 1;
  11.  
  12. int width = 100;
  13. int height = 25;
  14.  
  15. int pos[26];
  16. int delta[26];
  17. ConsoleColor co[26];
  18.  
  19. ConsoleColor colors[] = { ConsoleColor::Red,ConsoleColor::Blue, ConsoleColor::Yellow, ConsoleColor::Green };
  20.  
  21.  
  22. void update() {
  23.     for (int i = 0; i<26; i++) {
  24.         if (tim % delta[i] == 0) {
  25.             pos[i] = min(height, pos[i] + 1);
  26.         }
  27.     }
  28. }
  29. void render() {
  30.     for (int i = 0; i < 26; i++) {
  31.         int gap = width / 28;
  32.         Console::ForegroundColor = co[i];
  33.         Console::SetCursorPosition(gap * (i + 1), pos[i]);
  34.         cout << char('A' + i);
  35.     }
  36. }
  37. void erase() {
  38.     for (int i = 0; i < 26; i++) {
  39.         int gap = width / 28;
  40.         Console::SetCursorPosition(gap * (i + 1), pos[i]);
  41.         cout << " ";
  42.     }
  43. }
  44.  
  45.  
  46.  
  47. int main()
  48. {
  49.     srand(time(0));
  50.     Console::CursorVisible = false;
  51.  
  52.     for (int i = 0; i < 26; i++) {
  53.         pos[i] = 0;
  54.         delta[i] = rand() % 6 +4;
  55.         co[i] = colors[rand() % 4];
  56.     }
  57.  
  58.  
  59.  
  60.  
  61.     while (1) {
  62.         erase();
  63.         update();
  64.         render();
  65.         tim++;
  66.         _sleep(100);
  67.     }
  68.  
  69.  
  70.  
  71.     return 0;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement