Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.19 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3.  
  4. #define BLACK 0
  5. #define BLUE 1
  6. #define GREEN 2
  7. #define CYAN 3
  8. #define RED 4
  9. #define MAGENTA 5
  10. #define BROWN 6
  11. #define LIGHTGRAY 7
  12. #define DARKGRAY 8
  13. #define LIGHTBLUE 9
  14. #define LIGHTGREEN 10
  15. #define LIGHTCYAN 11
  16. #define LIGHTRED 12
  17. #define LIGHTMAGENTA 13
  18. #define YELLOW 14
  19. #define WHITE 15
  20.  
  21. int muevehorizontal(int x1, int y1, int x2,char cadena[],int largo);
  22. int muevevertical(int x1, int y1, int y2, char cadena[], int largo);
  23. void marco(int x1, int y1, int x2, int y2);
  24. int gotoxy(int,int);
  25. int textcolor(WORD);
  26.  
  27. // recorre letras de izq a derecha desde x1 a x2
  28. int muevehorizontal(int x1, int y1, int x2,char cadena[],int largo)
  29. {
  30.     int i,j;
  31.  
  32.  
  33.     for (j=largo-1;j>=0;j--,x2--)
  34.         for (i=x1; i<=x2;i++)
  35.         {
  36.             Sleep(5);
  37.             gotoxy(i,y1);
  38.             printf("%c",cadena[j]);
  39.             gotoxy(i-1,y1);
  40.             printf("%c",' ');
  41.         }
  42.     return 0;
  43. }
  44.  
  45. // simula caida de letras desde y1 a y2
  46. int muevevertical(int x1, int y1, int y2, char cadena[], int largo)
  47. {
  48. int i,j;
  49.  
  50.  
  51.     for (j=0;j<=largo;j++,x1++)
  52.         for (i=y1; i<=y2;i++)
  53.         {
  54.             Sleep(5);
  55.             gotoxy(x1,i);
  56.             printf("%c",cadena[j]);
  57.             gotoxy(x1,i-1);
  58.             printf("%c",' ');
  59.         }
  60.     return 0;
  61. }
  62.  
  63.  
  64. // despliega un marco desde x1 y1 hasta x2 y2
  65. void marco(int x1, int y1, int x2, int y2)
  66. {
  67.     int i;
  68.  
  69.     gotoxy(x1,y1);
  70.     printf("%c",201); //esquina superior izq
  71.     gotoxy(x1,y2);
  72.     printf("%c",200); //esquina inferior izq
  73.     gotoxy(x2,y1);
  74.     printf("%c",187); //esquina superior der
  75.     gotoxy(x2,y2);
  76.     printf("%c",188);  //esquina inferior der
  77.  
  78.     for (i=x1+1; i<x2;i++) // horizontales
  79.     {
  80.         Sleep(3);
  81.         gotoxy(i,y1);
  82.         printf("%c",205);
  83.         gotoxy(i,y2);
  84.         printf("%c",205);
  85.     }
  86.  
  87.     for (i=y1+1; i<y2;i++) // verticales
  88.         {
  89.             Sleep(5);
  90.             gotoxy(x1,i);
  91.             printf("%c",182);
  92.             gotoxy(x2,i);
  93.             printf("%c",182);
  94.         }
  95. }
  96.  
  97. // Posiciona cursor en x y
  98. int gotoxy(int x,int y)
  99. {
  100.     COORD scrn;
  101.     HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
  102.     scrn.X=x;
  103.     scrn.Y=y;
  104.     SetConsoleCursorPosition(hOutput,scrn);
  105.     return 0;
  106. }
  107.  
  108. // cambia el color de letras a escribir
  109. int textcolor(WORD wColor)
  110. {
  111.     HANDLE hHandle=GetStdHandle(STD_OUTPUT_HANDLE);
  112.     SetConsoleTextAttribute(hHandle,wColor);
  113.     return 0;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement