Write me a C++ console script with amazing state of the art graphics that looks cool
- User
Write me a C++ console script with amazing state of the art graphics that looks cool
Assistant
Here's a C++ console program that creates a visually striking animated display with particle effects, colors, and dynamic text:
#include <iostream> #include <windows.h> #include <conio.h> #include <vector> #include <random> #include <cmath> #include <string> class ConsoleGraphics { private: HANDLE hConsole; COORD screenSize; std::mt19937 rng; struct Particle { float x, y; float vx, vy; char character; int color; float life; }; std::vector<Particle> particles; public: ConsoleGraphics() : rng(std::random_device{}()) { hConsole = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hConsole, &csbi); screenSize = {80, 25}; // Hide cursor CONSOLE_CURSOR_INFO cursorInfo; GetConsoleCursorInfo(hConsole, &cursorInfo); cursorInfo.bVisible = false; SetConsoleCursorInfo(hConsole, &cursorInfo); // Set console size SetConsoleScreenBufferSize(hConsole, screenSize); SMALL_RECT windowSize = {0, 0, screenSize.X - 1, screenSize.Y - 1}; SetConsoleWindowInfo(hConsole, TRUE, &windowSize); } void SetColor(int color) { SetConsoleTextAttribute(hConsole, color); } void GotoXY(int x, int y) { COORD coord = {(SHORT)x, (SHORT)y}; SetConsoleCursorPosition(hConsole, coord); } void ClearScreen() { system("cls"); } void DrawPixel(int x, int y, char c, int color) { if (x >= 0 && x < screenSize.X && y >= 0 && y < screenSize.Y) { GotoXY(x, y); SetColor(color); std::cout << c; } } void CreateParticleExplosion(int centerX, int centerY) { std::uniform_real_distribution<float> angleDist(0, 2 * 3.14159f); std::uniform_real_distribution<float> speedDist(1.0f, 5.0f); std::uniform_int_distribution<int> colorDist(9, 15); for (int i = 0; i < 30; i++) { float angle = angleDist(rng); float speed = speedDist(rng); char chars[] = {'*', '+', 'o', '.', '#', '@'}; particles.push_back({ (float)centerX, (float)centerY, cos(angle) * speed, sin(angle) * speed, chars[i % 6], colorDist(rng), 1.0f }); } } void UpdateParticles() { for (auto it = particles.begin(); it != particles.end();) { it->x += it->vx * 0.5f; it->y += it->vy * 0.5f; it->vy += 0.1f; // gravity it->life -= 0.02f; if (it->life <= 0 || it->y >= screenSize.Y) { it = particles.erase(it); } else { ++it; } } } void DrawParticles() { for (const auto& p : particles) { int alpha = (int)(p.life * 15); DrawPixel((int)p.x, (int)p.y, p.character, alpha); } } void DrawWaveText(const std::string& text, int baseY, float time) { int startX = (screenSize.X - text.length()) / 2; for (size_t i = 0; i < text.length(); i++) { float wave = sin(time + i * 0.5f) * 2; int color = 9 + (int)(sin(time + i * 0.3f) * 3 + 3); DrawPixel(startX + i, baseY + (int)wave, text[i], color); } } void DrawFireEffect(int y) { std::uniform_int_distribution<int> colorDist(12, 14); std::uniform_real_distribution<float> flameDist(0, 1); for (int x = 0; x < screenSize.X; x++) { if (flameDist(rng) > 0.7f) { char fireChars[] = {'^', '*', '+', '.'}; char c = fireChars[rand() % 4]; DrawPixel(x, y, c, colorDist(rng)); } } } void DrawMatrix(float time) { static std::vector<int> columns(screenSize.X, 0); std::uniform_int_distribution<int> charDist(33, 126); for (int x = 0; x < screenSize.X; x++) { if (rand() % 10 == 0) { columns[x] = 0; } if (columns[x] < screenSize.Y) { DrawPixel(x, columns[x], charDist(rng), 10); if (columns[x] > 0) { DrawPixel(x, columns[x] - 1, charDist(rng), 2); } columns[x]++; } } } }; int main() { ConsoleGraphics graphics; float time = 0; int frame = 0; std::cout << "Press any key to start the show, ESC to exit...\n"; _getch(); while (true) { if (_kbhit()) { char key = _getch(); if (key == 27) break; // ESC key if (key == ' ') { // Create explosion at random location graphics.CreateParticleExplosion( rand() % 60 + 10, rand() % 15 + 5 ); } } graphics.ClearScreen(); // Background matrix effect if (frame % 3 == 0) { graphics.DrawMatrix(time); } // Fire effect at bottom graphics.DrawFireEffect(23); graphics.DrawFireEffect(24); // Animated title graphics.DrawWaveText("=== CYBER CONSOLE GRAPHICS ===", 5, time); graphics.DrawWaveText("Press SPACE for fireworks!", 15, time * 0.8f); // Update and draw particles graphics.UpdateParticles(); graphics.DrawParticles(); // Rotating border int borderColor = 9 + (int)(sin(time) * 3 + 3); for (int i = 0; i < 80; i++) { if ((i + frame) % 8 < 4) { graphics.DrawPixel(i, 0, '=', borderColor); graphics.DrawPixel(i, 24, '=', borderColor); } } time += 0.2f; frame++; Sleep(50); // ~20 FPS } graphics.SetColor(7); graphics.ClearScreen(); std::cout << "Thanks for watching the show!\n"; return 0; }This program creates several cool visual effects:
Features:
- Matrix-style falling characters in the background
- Animated wave text with color cycling
- Particle explosion system (press SPACE for fireworks!)
- Fire effect at the bottom of the screen
- Animated borders with rotating patterns
- Real-time color changes and smooth animations
Controls:
- SPACE - Create particle explosions
- ESC - Exit the program
Visual Elements:
- Dynamic particle physics with gravity
- Sine wave text animations
- Color cycling effects
- Multiple layered visual systems
- Smooth 20 FPS animation
Note: This uses Windows-specific console functions. For cross-platform compatibility, you could replace the Windows console functions with ncurses (Linux/Mac) or ANSI escape sequences for colors and cursor positioning.
The result is a surprisingly impressive visual display that pushes the boundaries of what's possible in a text console!
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.