Space Shooter: High-Speed Console Engine
A high-performance CLI-based Space Shooter implemented in C++. Utilizing Pthreads for asynchronous input processing and ANSI escape sequences for flicker-free terminal rendering, this engine delivers a smooth arcade experience directly within the system console.
°
°
°
°
Technical Architecture
The game engine is designed for maximum efficiency in a text-buffered environment, featuring a dual-thread execution model:
- Multithreaded Input (Pthreads): Decouples the user input (
getch) from the main game loop, ensuring that the game physics and rendering continue to execute without waiting for keyboard hits.
- ANSI Render Pipeline: Uses a character buffer (
buff[5000]) to build entire frames in memory before flushing them to the console using escape sequences (\e[1;1H), eliminating common terminal flicker.
- Collision Engine: Implements precise hit-box logic (
HitTest) based on character coordinate intersections between the 3-line player craft and enemy entities.
- Hardware Optimization: Utilizes
SetConsoleCursorInfo via the Windows API to hide the flickering hardware cursor, providing a clean graphical interface.
Project Structure
ArcadeSpaceShooter_Console/
├── LICENSE # MIT License
├── README.md # Project documentation
│
├── consoleMode/ # Core Source & Project Files
│ ├── main.cpp # Multi-threaded Engine Logic
│ ├── SpaceShooter.cbp # Code::Blocks Project
│ └── bin/Debug/ # Compiled binaries
│
└── Screenshots/ # CLI Visual Preview Gallery
├── consoleMode_v1.png
├── consoleMode_v2.png
└── ...
Game Mechanics
- ASCII Entity Modeling: Detailed multi-character sprite designs for both the player shuttle and enemy cruisers.
- Asynchronous Movement: Silky-smooth vertical transition and high-speed projectile firing.
- Infinite Challenge: Procedural enemy spawning with randomized vertical positioning.
- Performance Controls: Configurable
FIRERATE and SPEED variables for manual difficulty calibration.
- Hit-Box Precision: Accurate detection across multiple character lines.
Player Controls
| Action |
Key |
| Ascend |
W |
| Descend |
S |
| Fire Projectile |
Space |
| Quit Game |
Q |
Technical Specifications
| Component |
Specification |
| Language |
C++ (ISO Standard) |
| Threading |
POSIX Threads (pthread.h) |
| Terminal Rendering |
ANSI Escape Sequences |
| Viewport |
34 x 19 Character Matrix |
| OS Target |
Windows Console (WinAPI optimized) |
Deployment & Installation
1. Repository Acquisition
git clone https://github.com/Zer0-Bug/ArcadeSpaceShooter_Console.git
cd ArcadeSpaceShooter_Console
2. Compilation
The project supports compilation via any standard C++ compiler with thread support (e.g., MinGW/GCC).
Via CLI (GCC):
g++ consoleMode/main.cpp -o space-shooter -lpthread
Via Code::Blocks:
- Open
consoleMode/SpaceShooter.cbp.
- Ensure the
pthreads library is linked in Build Options.
- Build and run (F9).
3. Execution
Simply run the compiled binary to start the game loop:
./space-shooter
Contribution
Contributions are always appreciated. Open-source projects grow through collaboration, and any improvement—whether a bug fix, new feature, documentation update, or suggestion—is valuable.
To contribute, please follow the steps below:
- Fork the repository.
- Create a new branch for your change:
git checkout -b feature/your-feature-name
- Commit your changes with a clear and descriptive message:
git commit -m "Add: brief description of the change"
- Push your branch to your fork:
git push origin feature/your-feature-name
- Open a Pull Request describing the changes made.
All contributions are reviewed before being merged. Please ensure that your changes follow the existing code style and include relevant documentation or tests where applicable.
×
∞
评论