Guest User

Untitled

a guest
May 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <unistd.h>
  4.  
  5. const char *text = " --- === JESTEM PEDAŁEM === --- ";
  6. const int xmax = 80;
  7. const int ymax = 24;
  8.  
  9. void goto_xy(int x, int y)
  10. {
  11. printf("\033[%d;%dH", y, x);
  12. }
  13.  
  14. void set_colours(int a, int b)
  15. {
  16. a %= 8;
  17. b %= 8;
  18. printf("\033[%d;%dm", a+30, b+40);
  19. }
  20.  
  21. void clrscr(int a, int b)
  22. {
  23. int i = ymax;
  24. set_colours(a,b);
  25. while(i--){
  26. goto_xy(0,i);
  27. int j=xmax;
  28. while(j--)
  29. putchar(' ');
  30. }
  31.  
  32. }
  33.  
  34. int main()
  35. {
  36. clrscr(5,6);
  37. int textlen = strlen(text);
  38. int n = xmax-textlen+1;
  39. while(1){
  40. int i;
  41. for(i=1; i<=n; ++i){
  42. goto_xy(i, ymax/2);
  43. printf("%s", text);
  44. fflush(stdout);
  45. usleep(80*1000);
  46. }
  47. for(i=n; i>=1; --i){
  48. goto_xy(i, ymax/2);
  49. printf("%s", text);
  50. fflush(stdout);
  51. usleep(80*1000);
  52. }
  53.  
  54. }
  55. return 0;
  56. }
Add Comment
Please, Sign In to add comment