Advertisement
Guest User

Untitled

a guest
Oct 16th, 2023
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/ioctl.h>
  5. #include <termios.h>
  6. #include <time.h>
  7.  
  8. // Function to get the screen size
  9. void getScreenSize(int *width, int *height) {
  10. struct winsize ws;
  11. ioctl(0, TIOCGWINSZ, &ws);
  12. *width = ws.ws_col;
  13. *height = ws.ws_row;
  14. }
  15.  
  16. // Function to generate a random number between min and max
  17. int getRandomNumber(int min, int max) {
  18. return min + rand() % (max - min + 1);
  19. }
  20.  
  21. // Function to change the text color
  22. void changeColor(int color) {
  23. printf("\033[38;5;%dm", color);
  24. }
  25.  
  26. int main() {
  27. int x = 0;
  28. int y = 0;
  29. int dx = 1;
  30. int dy = 1;
  31.  
  32. int screenWidth, screenHeight;
  33. getScreenSize(&screenWidth, &screenHeight);
  34.  
  35. // Seed the random number generator with current time
  36. srand(time(NULL));
  37.  
  38. int randomColor = getRandomNumber(0, 255);
  39.  
  40. while (1) {
  41. // Clear the screen
  42. system("clear");
  43.  
  44. // Update the position
  45. x += dx;
  46. y += dy;
  47.  
  48. // Check for collision with screen edges
  49. if (x <= 0 || x >= screenWidth - 30) {
  50. dx = -dx;
  51. }
  52. if (y <= 0 || y >= screenHeight - 8) {
  53. dy = -dy;
  54. }
  55.  
  56. // Generate a new random color every three seconds
  57. if (time(NULL) % 3 == 0) {
  58. randomColor = getRandomNumber(0, 255);
  59. }
  60.  
  61. // Print the logo at the current position with the random color
  62. changeColor(randomColor);
  63. for (int i = 0; i < y; i++) {
  64. printf("\n");
  65. }
  66. for (int i = 0; i < x; i++) {
  67. printf(" ");
  68. }
  69. printf("⠀⠀⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣶⣦⡀\n");
  70. for (int i = 0; i < x; i++) {
  71. printf(" ");
  72. }
  73. printf("⠀⢠⣿⣿⡿⠀⠀⠈⢹⣿⣿⡿⣿⣿⣇⠀⣠⣿⣿⠟⣽⣿⣿⠇⠀⠀⢹⣿⣿⣿\n");
  74. for (int i = 0; i < x; i++) {
  75. printf(" ");
  76. }
  77. printf("⠀⢸⣿⣿⡇⠀⢀⣠⣾⣿⡿⠃⢹⣿⣿⣶⣿⡿⠋⢰⣿⣿⡿⠀⠀⣠⣼⣿⣿⠏\n");
  78. for (int i = 0; i < x; i++) {
  79. printf(" ");
  80. }
  81. printf("⠀⣿⣿⣿⣿⣿⣿⠿⠟⠋⠁⠀⠀⢿⣿⣿⠏⠀⠀⢸⣿⣿⣿⣿⣿⡿⠟⠋⠁⠀\n");
  82. for (int i = 0; i < x; i++) {
  83. printf(" ");
  84. }
  85. printf("⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣸⣟⣁⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀\n");
  86. for (int i = 0; i < x; i++) {
  87. printf(" ");
  88. }
  89. printf("⣠⣴⣶⣾⣿⣿⣻⡟⣻⣿⢻⣿⡟⣛⢻⣿⡟⣛⣿⡿⣛⣛⢻⣿⣿⣶⣦⣄⡀⠀\n");
  90. for (int i = 0; i < x; i++) {
  91. printf(" ");
  92. }
  93. printf("⠉⠛⠻⠿⠿⠿⠷⣼⣿⣿⣼⣿⣧⣭⣼⣿⣧⣭⣿⣿⣬⡭⠾⠿⠿⠿⠛⠉⠀\n");
  94.  
  95. // Reset the text color to default
  96. printf("\033[0m");
  97.  
  98. // Wait for a short period of time
  99. usleep(100000);
  100. }
  101.  
  102. return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement