Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <sys/ioctl.h>
- #include <termios.h>
- #include <time.h>
- // Function to get the screen size
- void getScreenSize(int *width, int *height) {
- struct winsize ws;
- ioctl(0, TIOCGWINSZ, &ws);
- *width = ws.ws_col;
- *height = ws.ws_row;
- }
- // Function to generate a random number between min and max
- int getRandomNumber(int min, int max) {
- return min + rand() % (max - min + 1);
- }
- // Function to change the text color
- void changeColor(int color) {
- printf("\033[38;5;%dm", color);
- }
- int main() {
- int x = 0;
- int y = 0;
- int dx = 1;
- int dy = 1;
- int screenWidth, screenHeight;
- getScreenSize(&screenWidth, &screenHeight);
- // Seed the random number generator with current time
- srand(time(NULL));
- int randomColor = getRandomNumber(0, 255);
- while (1) {
- // Clear the screen
- system("clear");
- // Update the position
- x += dx;
- y += dy;
- // Check for collision with screen edges
- if (x <= 0 || x >= screenWidth - 30) {
- dx = -dx;
- }
- if (y <= 0 || y >= screenHeight - 8) {
- dy = -dy;
- }
- // Generate a new random color every three seconds
- if (time(NULL) % 3 == 0) {
- randomColor = getRandomNumber(0, 255);
- }
- // Print the logo at the current position with the random color
- changeColor(randomColor);
- for (int i = 0; i < y; i++) {
- printf("\n");
- }
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⡀\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠀⢠⣿⣿⡿⠀⠀⠈⢹⣿⣿⡿⣿⣿⣇⠀⣠⣿⣿⠟⣽⣿⣿⠇⠀⠀⢹⣿⣿⣿\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠀⢸⣿⣿⡇⠀⢀⣠⣾⣿⡿⠃⢹⣿⣿⣶⣿⡿⠋⢰⣿⣿⡿⠀⠀⣠⣼⣿⣿⠏\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠀⣿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⢿⣿⣿⠏⠀⠀⢸⣿⣿⣿⣿⣿⡿⠟⠋⠁⠀\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣸⣟⣁⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⣠⣴⣶⣾⣿⣿⣻⡟⣻⣿⢻⣿⡟⣛⢻⣿⡟⣛⣿⡿⣛⣛⢻⣿⣿⣶⣦⣄⡀⠀\n");
- for (int i = 0; i < x; i++) {
- printf(" ");
- }
- printf("⠉⠛⠻⠿⠿⠿⠷⣼⣿⣿⣼⣿⣧⣭⣼⣿⣧⣭⣿⣿⣬⡭⠾⠿⠿⠿⠛⠉⠀\n");
- // Reset the text color to default
- printf("\033[0m");
- // Wait for a short period of time
- usleep(100000);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement