grifo
27-sep-2005, 03:50
Este fue mi primer proyecto para este semestre, en programacion, lo quiero compartir con ustedes, espero les guste y practiquen, y si lo mejoran y le colocan mas cosas, diganme, a ver si tambien puedo jejejeje.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<string.h>
class rectangulo
{
private:
int largo; // ALTO DEL RECTANGULO
int ancho; // ANCHO DEL RECTANGULO
int i,j,x,y;
int leetecla();
char mensaje[81]; // VECTOR PARA LA FRASE
public:
void dibuja(); // DIBUJA RECTANGULO
void pedir(); // PIDE FRASE
void mover(); // MUEVE FRASE, LA HACE CAER
void run(); // CORRE LAS FUNCIONES
rectangulo()
{
mensaje[0]=81;
largo=10;
ancho=10;
run();
}
};
/////////////////////////////////////////////////////////////////////
void rectangulo::dibuja()
{
while(!kbhit()) // MIENTRAS NO SE PULSE UNA TECLA
{
x=random(79-ancho)+1; // CORDENADA EN X DE 2-80
y=random(49-largo)+1; // CORDENADA EN Y DE 2-50
clrscr();
textcolor(YELLOW);
// PRIMERO LAS ESQUINAS
gotoxy(x,y); cprintf("Ú");
gotoxy(x+ancho,y); cprintf("¿");
textcolor(BLUE);
gotoxy(x,largo+y); cprintf("À");
gotoxy(x+ancho,largo+y); cprintf("Ù");
for(i=1;i<ancho;i++) // LINEAS HORIZONTALES
{
textcolor(YELLOW);
gotoxy(i+x,y); cprintf("Ä");
textcolor(BLUE);
gotoxy(i+x,largo+y); cprintf("Ä");
}
for(j=1;j<largo;j++) // LINEAS VERTICALES
{
textcolor(RED);
gotoxy(x,j+y); cprintf("³");
gotoxy(ancho+x,j+y); cprintf("³");
}
delay(250); // ESPERA 250 MILISEG
}
}
/////////////////////////////////////////////////////////////
void rectangulo::pedir()
{
clrscr();
textcolor(6);
gotoxy(1,1); cprintf("Digite una frase\n");
gotoxy(1,2); cgets(mensaje); // CAPTURANDO
}
/////////////////////////////////////////////////////////
void rectangulo::mover()
{
clrscr();
int p = (80-strlen(mensaje))/2; // CENTRA LA FRASE
for(int z=2;z<strlen(mensaje);z++) // IMPRIME FRASE
{ gotoxy(p+z,25); cprintf("%c",mensaje[z]); }
for(int k=2;k<strlen(mensaje);k++) // CORRE EL VECTOR
{
for(int q=0;q<=25;q++) // BAJA LAS LETRAS
{
gotoxy(p+k,(25)+q); cprintf("%c",mensaje[k]);
delay(7);
gotoxy(p+k,(25)+q); cprintf(" ");
if(q==25)
{ gotoxy(p+k,50); cprintf("%c",mensaje[k]); } // IMPRIME LA FRASE ABAJO
}
}
}
///////////////////////////////////////////////
int rectangulo::leetecla()
{
int tecla=0;
tecla=getch();
if(tecla==0)
tecla=getch();
return tecla;
}
////////////////////////////////////////////////
void rectangulo::run()
{
randomize();
clrscr();
while(leetecla()!=59)
dibuja();
pedir();
mover();
}
///////////////////////////////////////////////
void main()
{
rectangulo rec; // OBJETO
}
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<string.h>
class rectangulo
{
private:
int largo; // ALTO DEL RECTANGULO
int ancho; // ANCHO DEL RECTANGULO
int i,j,x,y;
int leetecla();
char mensaje[81]; // VECTOR PARA LA FRASE
public:
void dibuja(); // DIBUJA RECTANGULO
void pedir(); // PIDE FRASE
void mover(); // MUEVE FRASE, LA HACE CAER
void run(); // CORRE LAS FUNCIONES
rectangulo()
{
mensaje[0]=81;
largo=10;
ancho=10;
run();
}
};
/////////////////////////////////////////////////////////////////////
void rectangulo::dibuja()
{
while(!kbhit()) // MIENTRAS NO SE PULSE UNA TECLA
{
x=random(79-ancho)+1; // CORDENADA EN X DE 2-80
y=random(49-largo)+1; // CORDENADA EN Y DE 2-50
clrscr();
textcolor(YELLOW);
// PRIMERO LAS ESQUINAS
gotoxy(x,y); cprintf("Ú");
gotoxy(x+ancho,y); cprintf("¿");
textcolor(BLUE);
gotoxy(x,largo+y); cprintf("À");
gotoxy(x+ancho,largo+y); cprintf("Ù");
for(i=1;i<ancho;i++) // LINEAS HORIZONTALES
{
textcolor(YELLOW);
gotoxy(i+x,y); cprintf("Ä");
textcolor(BLUE);
gotoxy(i+x,largo+y); cprintf("Ä");
}
for(j=1;j<largo;j++) // LINEAS VERTICALES
{
textcolor(RED);
gotoxy(x,j+y); cprintf("³");
gotoxy(ancho+x,j+y); cprintf("³");
}
delay(250); // ESPERA 250 MILISEG
}
}
/////////////////////////////////////////////////////////////
void rectangulo::pedir()
{
clrscr();
textcolor(6);
gotoxy(1,1); cprintf("Digite una frase\n");
gotoxy(1,2); cgets(mensaje); // CAPTURANDO
}
/////////////////////////////////////////////////////////
void rectangulo::mover()
{
clrscr();
int p = (80-strlen(mensaje))/2; // CENTRA LA FRASE
for(int z=2;z<strlen(mensaje);z++) // IMPRIME FRASE
{ gotoxy(p+z,25); cprintf("%c",mensaje[z]); }
for(int k=2;k<strlen(mensaje);k++) // CORRE EL VECTOR
{
for(int q=0;q<=25;q++) // BAJA LAS LETRAS
{
gotoxy(p+k,(25)+q); cprintf("%c",mensaje[k]);
delay(7);
gotoxy(p+k,(25)+q); cprintf(" ");
if(q==25)
{ gotoxy(p+k,50); cprintf("%c",mensaje[k]); } // IMPRIME LA FRASE ABAJO
}
}
}
///////////////////////////////////////////////
int rectangulo::leetecla()
{
int tecla=0;
tecla=getch();
if(tecla==0)
tecla=getch();
return tecla;
}
////////////////////////////////////////////////
void rectangulo::run()
{
randomize();
clrscr();
while(leetecla()!=59)
dibuja();
pedir();
mover();
}
///////////////////////////////////////////////
void main()
{
rectangulo rec; // OBJETO
}