Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <windows.h>
- #define BLACK 0
- #define BLUE 1
- #define GREEN 2
- #define CYAN 3
- #define RED 4
- #define MAGENTA 5
- #define BROWN 6
- #define LIGHTGRAY 7
- #define DARKGRAY 8
- #define LIGHTBLUE 9
- #define LIGHTGREEN 10
- #define LIGHTCYAN 11
- #define LIGHTRED 12
- #define LIGHTMAGENTA 13
- #define YELLOW 14
- #define WHITE 15
- int muevehorizontal(int x1, int y1, int x2,char cadena[],int largo);
- int muevevertical(int x1, int y1, int y2, char cadena[], int largo);
- void marco(int x1, int y1, int x2, int y2);
- int gotoxy(int,int);
- int textcolor(WORD);
- // recorre letras de izq a derecha desde x1 a x2
- int muevehorizontal(int x1, int y1, int x2,char cadena[],int largo)
- {
- int i,j;
- for (j=largo-1;j>=0;j--,x2--)
- for (i=x1; i<=x2;i++)
- {
- Sleep(5);
- gotoxy(i,y1);
- printf("%c",cadena[j]);
- gotoxy(i-1,y1);
- printf("%c",' ');
- }
- return 0;
- }
- // simula caida de letras desde y1 a y2
- int muevevertical(int x1, int y1, int y2, char cadena[], int largo)
- {
- int i,j;
- for (j=0;j<=largo;j++,x1++)
- for (i=y1; i<=y2;i++)
- {
- Sleep(5);
- gotoxy(x1,i);
- printf("%c",cadena[j]);
- gotoxy(x1,i-1);
- printf("%c",' ');
- }
- return 0;
- }
- // despliega un marco desde x1 y1 hasta x2 y2
- void marco(int x1, int y1, int x2, int y2)
- {
- int i;
- gotoxy(x1,y1);
- printf("%c",201); //esquina superior izq
- gotoxy(x1,y2);
- printf("%c",200); //esquina inferior izq
- gotoxy(x2,y1);
- printf("%c",187); //esquina superior der
- gotoxy(x2,y2);
- printf("%c",188); //esquina inferior der
- for (i=x1+1; i<x2;i++) // horizontales
- {
- Sleep(3);
- gotoxy(i,y1);
- printf("%c",205);
- gotoxy(i,y2);
- printf("%c",205);
- }
- for (i=y1+1; i<y2;i++) // verticales
- {
- Sleep(5);
- gotoxy(x1,i);
- printf("%c",182);
- gotoxy(x2,i);
- printf("%c",182);
- }
- }
- // Posiciona cursor en x y
- int gotoxy(int x,int y)
- {
- COORD scrn;
- HANDLE hOutput=GetStdHandle(STD_OUTPUT_HANDLE);
- scrn.X=x;
- scrn.Y=y;
- SetConsoleCursorPosition(hOutput,scrn);
- return 0;
- }
- // cambia el color de letras a escribir
- int textcolor(WORD wColor)
- {
- HANDLE hHandle=GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hHandle,wColor);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement