Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include "enemigo.h"
- #include <conio.h>
- using namespace std;
- using namespace System;
- int x = 30;
- int tim = 1;
- int width = 100;
- int height = 25;
- int pos[26];
- int delta[26];
- ConsoleColor co[26];
- ConsoleColor colors[] = { ConsoleColor::Red,ConsoleColor::Blue, ConsoleColor::Yellow, ConsoleColor::Green };
- void update() {
- for (int i = 0; i<26; i++) {
- if (tim % delta[i] == 0) {
- pos[i] = min(height, pos[i] + 1);
- }
- }
- }
- void render() {
- for (int i = 0; i < 26; i++) {
- int gap = width / 28;
- Console::ForegroundColor = co[i];
- Console::SetCursorPosition(gap * (i + 1), pos[i]);
- cout << char('A' + i);
- }
- }
- void erase() {
- for (int i = 0; i < 26; i++) {
- int gap = width / 28;
- Console::SetCursorPosition(gap * (i + 1), pos[i]);
- cout << " ";
- }
- }
- int main()
- {
- srand(time(0));
- Console::CursorVisible = false;
- for (int i = 0; i < 26; i++) {
- pos[i] = 0;
- delta[i] = rand() % 6 +4;
- co[i] = colors[rand() % 4];
- }
- while (1) {
- erase();
- update();
- render();
- tim++;
- _sleep(100);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement