Backup proyecto Joyfe - Borland

This commit is contained in:
2025-06-16 22:54:10 +02:00
commit d61829a1a7
130 changed files with 11881 additions and 0 deletions

552
CPP/PROG11.CPP Normal file
View File

@ -0,0 +1,552 @@
// Prog9
//
// Programadores:
//
// Juan L<>pez Fern<72>ndez
// Mois<69>s Virumbrales Cuenca
// DAI 1<>A
//
#include<stdio.h>
#include<conio.h>
char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[],
int color_titulo,int posx,int posy);
int intentos(int nivel,int niv,int n);
char psoga();char pcabeza();char pcaraa(); char pcarat();char pcuerpo();
char pextremidades(int lado);char dibujar(int niv,int fallo);
void main() {
int numero[9],n=0,nivel=0,num,tabla[9],color_num[10],niv=0,soga[5][5];
int cabeza[7][7],fallo=0;
for (int aux=0;aux<9;aux++)
tabla[aux]=10;
for (int auxi=0;auxi<=9;auxi++)
color_num[auxi]=0;
textbackground(0);
clrscr();
ventana(80,24,7,1,"Juego del Ahorcado",14,1,1);
textcolor(6);
gotoxy(6,22);
ventana(45,7,7,8,"H",1,20,10);
ventana(45,7,7,1,"Valores iniciales del juego",14,18,9);
textcolor(0);
textbackground(7);
gotoxy(21,11);
cprintf ("Introduce nivel de dificultad(1-7): ");
textcolor(0);
fflush(stdin);
cscanf("%1d",&nivel);
gotoxy(21,13);
cprintf ("Introducir n<>mero a adivinar: ");
do {
textcolor(0);
textbackground(0);
gotoxy(51,13);
fflush(stdin);
cscanf ("%1d",&numero[n]);
n++;
gotoxy (51,13);
textcolor(0);
textbackground(7);
cprintf ("_");
} while (n<nivel);
textbackground(0);
clrscr();
ventana(80,24,7,1,"Juego del Ahorcado",14,1,1);
if (nivel!=6 && nivel!=7)
psoga();
ventana(25,7,7,8,"",8,10,5);
ventana(25,7,7,1,"Estado del juego",14,8,4);
gotoxy(12,6);
textbackground(7);
for (n=0;n<nivel;n++) {
textcolor(0);
cprintf ("_");
textcolor(7);
cprintf (" ");
}
gotoxy (11,8);
for (int number=0;number<=9;number++) {
textcolor(0);
cprintf ("%d",number);
textcolor(7);
cprintf (" ");
}
int sw=1;
ventana(30,7,7,8,"",8,9,15);
ventana(30,7,7,1,"Introducci<EFBFBD>n del n<>mero",14,7,14);
if (nivel==1)
niv=6;
else
if (nivel==2)
niv=5;
else
if (nivel==3)
niv=5;
else
if (nivel==4)
niv=6;
else
if (nivel==5)
niv=6;
else
if (nivel==6)
niv=7;
else
niv=7;
gotoxy(10,18);
textcolor(0);
textbackground(7);
cprintf ("Intentos: ");
textcolor(2);cprintf ("0");textcolor(0);cprintf (" de %d",niv);
for (n=1;n<=niv && sw==1;n++) {
textcolor(0);
textbackground(7);
gotoxy(10,16);
cprintf ("Introduce n<>mero: ");
fflush(stdin);
cscanf ("%1d",&num);
color_num[num]=1;
for (int j=0;j<nivel;j++)
if (numero[j]==num)
tabla[j]=num;
else {
fallo++;
dibujar(niv,fallo);
}
gotoxy(12,6);
for (int i=0;i<nivel;i++) {
textbackground(7);
if (tabla[i]==10) {
textcolor(0);
cprintf ("_");
}
else {
textcolor(5);
cprintf ("%d",tabla[i]);
}
textcolor(7);
cprintf (" ");
}
for (int k=0,con=0;k<nivel;k++)
if (tabla[k]!=10) {
con++;
}
if (con==nivel)
sw=0;
textbackground(7);
gotoxy (11,8);
for (int number=0;number<=9;number++) {
if (color_num[number]==1) {
textcolor(4);
cprintf ("%d",number);
}
else {
textcolor(0);
cprintf ("%d",number);
}
textcolor(7);
cprintf (" ");
}
intentos(nivel,niv,n);
}
if (sw==0) {
ventana(25,5,7,8,"",8,28,11);
ventana(25,5,7,4,"Fin del juego",14,26,10);
gotoxy(31,12);
textcolor(0+BLINK);
textbackground(7);
cprintf ("<EFBFBD><EFBFBD> Ha ganado !!");
}
else {
ventana(30,7,7,8,"",8,26,10);
ventana(30,7,7,4,"Fin del juego",14,24,9);
gotoxy(28,11);
textcolor(0);
textbackground(7);
cprintf ("Ha perdido");
gotoxy(28,13);
cprintf ("El n<>mero era: ");
for (int b=0;b<nivel;b++)
cprintf ("%d",numero[b]);
}
getch();
}
// ******************FIN DE PROGRAMA PRINCIPAL************************
char ventana (int ancho,int largo,int color_g,int color_borde,char titulo[80],
int color_titulo,int posx,int posy) {
int x,y,cony,conx;
char dib;
dib='<EFBFBD>';
for (cony=0,y=posy;cony<largo;cony++,y++){
for (conx=0,x=posx;conx<ancho;conx++,x++) {
gotoxy(x,y);
if (x==posx || y==posy || y==(posy+(largo-1)) || x==(posx+1)
|| x==(posx+(ancho-2)) || x==(posx+(ancho-1)))
textcolor(color_borde);
else
textcolor(color_g);
cprintf ("%c",dib);
}
}
gotoxy((posx+2),posy);
textcolor(color_titulo);
textbackground(color_borde);
cprintf("%s",titulo);
return(0);
}
// Funci<63>n color de intentos.
int intentos(int nivel,int niv,int n) {
gotoxy(10,18);
textbackground(7);
if (nivel==1 || nivel==4 || nivel==5) {
if (n<3) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(2);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else
if (n<5) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(14);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else {
textcolor(0);
cprintf ("Intentos: ");
textcolor(4+BLINK);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
}
if (nivel==2 || nivel==3) {
if (n<3) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(2);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else
if (n<4) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(14);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else {
textcolor(0);
cprintf ("Intentos: ");
textcolor(4+BLINK);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
}
if (nivel==6 || nivel==7) {
if (n<4) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(2);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else
if (n<6) {
textcolor(0);
cprintf ("Intentos: ");
textcolor(14);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
else {
textcolor(0);
cprintf ("Intentos: ");
textcolor(4+BLINK);
cprintf ("%d",n);
textcolor(0);
cprintf (" de %d",niv);
}
}
return(0);
}
// Dibujar.
char dibujar (int niv,int fallo) {
if (niv==5)
switch (fallo) {
case 1:
pcabeza();
pcaraa();
break;
case 2:
pcuerpo();
break;
case 3:
pextremidades(3);
pextremidades(4);
break;
case 4:
pextremidades(1);
break;
case 5:
pextremidades(2);
pcarat();
break;
}
else
if (niv==6)
switch (fallo) {
case 1:
pcabeza();
pcaraa();
break;
case 2:
pcuerpo();
break;
case 3:
pextremidades(3);
break;
case 4:
pextremidades(4);
break;
case 5:
pextremidades(1);
break;
case 6:
pextremidades(2);
pcarat();
break;
}
else
if (niv==7)
switch (fallo) {
case 1:
psoga();
break;
case 2:
pcabeza();
pcaraa();
break;
case 3:
pcuerpo();
break;
case 4:
pextremidades(3);
break;
case 5:
pextremidades(4);
break;
case 6:
pextremidades(1);
break;
case 7:
pextremidades(2);
pcarat();
break;
}
return (0);
}
// Pintar soga.
char psoga(){
int soga[12][7];
soga[0][3]='<EFBFBD>';soga[1][3]='<EFBFBD>';soga[2][3]='<EFBFBD>';soga[3][3]='<EFBFBD>';soga[4][3]='<EFBFBD>';
soga[5][2]='<EFBFBD>';soga[5][4]='<EFBFBD>';soga[6][1]='<EFBFBD>';soga[6][5]='<EFBFBD>';soga[7][0]='<EFBFBD>';
soga[7][6]='<EFBFBD>';soga[8][0]='<EFBFBD>';soga[8][6]='<EFBFBD>';soga[9][0]='<EFBFBD>';soga[9][6]='<EFBFBD>';
soga[10][1]='<EFBFBD>';soga[10][5]='<EFBFBD>';soga[11][2]='<EFBFBD>';soga[11][3]='<EFBFBD>';
soga[11][4]='<EFBFBD>';
for (int f=2,y=2;f<12;f++,y++) {
gotoxy(60,y);
for (int c=0;c<7;c++) {
if (soga[f][c]=='<EFBFBD>') {
textcolor(14);
cprintf ("%c",soga[f][c]);
}
else {
textcolor(7);
cprintf ("<EFBFBD>");
}
}
}
return(0);
}
// pintar cabeza
char pcabeza() {
int cabeza[5][7],pelo[2][7];
cabeza[0][1]='<EFBFBD>';cabeza[0][2]='<EFBFBD>';cabeza[0][3]='<EFBFBD>';cabeza[0][4]='<EFBFBD>';
cabeza[0][5]='<EFBFBD>';cabeza[1][0]='<EFBFBD>';cabeza[1][1]='<EFBFBD>';cabeza[1][2]='<EFBFBD>';
cabeza[1][3]='<EFBFBD>';cabeza[1][4]='<EFBFBD>';cabeza[1][5]='<EFBFBD>';cabeza[1][6]='<EFBFBD>';
cabeza[2][0]='<EFBFBD>';cabeza[2][1]='<EFBFBD>';cabeza[2][2]='<EFBFBD>';cabeza[2][3]='<EFBFBD>';
cabeza[2][4]='<EFBFBD>';cabeza[2][5]='<EFBFBD>';cabeza[2][6]='<EFBFBD>';
cabeza[3][1]='<EFBFBD>';cabeza[3][2]='<EFBFBD>';cabeza[3][3]='<EFBFBD>';cabeza[3][4]='<EFBFBD>';
cabeza[3][5]='<EFBFBD>';cabeza[4][2]='<EFBFBD>';cabeza[4][3]='<EFBFBD>';cabeza[4][4]='<EFBFBD>';
for (int f=0,y=6;f<5;f++,y++) {
gotoxy(60,y);
for (int c=0;c<7;c++) {
if (cabeza[f][c]=='<EFBFBD>') {
textcolor(6);
cprintf ("%c",cabeza[f][c]);
}
else {
textcolor(14);
cprintf ("<EFBFBD>");
}
}
}
// Pintar pelo
pelo[0][0]='<EFBFBD>';pelo[0][1]='<EFBFBD>';pelo[0][2]='<EFBFBD>';pelo[0][3]='<EFBFBD>';
pelo[0][4]='<EFBFBD>';pelo[0][5]='<EFBFBD>';pelo[0][6]='<EFBFBD>';pelo[1][0]='<EFBFBD>';
pelo[1][6]='<EFBFBD>';
for (f=0,y=5;f<2;f++,y++) {
gotoxy(60,y);
for (int c=0;c<7;c++) {
if (pelo[f][c]=='<EFBFBD>') {
textcolor(0);
cprintf ("%c",pelo[f][c]);
}
else {
textcolor(6);
cprintf ("<EFBFBD>");
}
}
}
return (0);
}
// Pintar cara alegre.
char pcaraa() {
// Pintar ojos
textbackground(6);textcolor(0);
gotoxy (62,7);cprintf ("O");
gotoxy (64,7);cprintf ("O");
// Pintar nariz.
gotoxy(63,8);cprintf("U");
// Pintar boca.
gotoxy(62,9);cprintf("<EFBFBD>");
gotoxy(64,9);cprintf("<EFBFBD>");
gotoxy(63,9);cprintf("-");
return(0);
}
// Pintar cara triste.
char pcarat() {
// Pintar ojos
textbackground(6);textcolor(0);
gotoxy (62,7);cprintf ("*");
gotoxy (64,7);cprintf ("*");
// Pintar nariz.
gotoxy(63,8);cprintf("U");
// Pintar boca.
gotoxy(62,9);cprintf("+");
gotoxy(64,9);cprintf("+");
gotoxy(63,9);cprintf("+");
return(0);
}
// Pintar cuerpo.
char pcuerpo() {
ventana(11,5,9,9,"",9,58,12);
return(0);
}
// Pinta extremidades
char pextremidades(int lado) {
int piernad[5][9];
piernad[0][0]='<EFBFBD>';piernad[0][1]='<EFBFBD>';piernad[0][2]='<EFBFBD>';piernad[0][3]='<EFBFBD>';
piernad[1][1]='<EFBFBD>';piernad[1][2]='<EFBFBD>';piernad[1][3]='<EFBFBD>';piernad[1][4]='<EFBFBD>';
piernad[2][2]='<EFBFBD>';piernad[2][3]='<EFBFBD>';piernad[2][4]='<EFBFBD>';piernad[2][5]='<EFBFBD>';
piernad[3][3]='<EFBFBD>';piernad[3][4]='<EFBFBD>';piernad[3][5]='<EFBFBD>';piernad[3][6]='<EFBFBD>';
piernad[4][4]='<EFBFBD>';piernad[4][5]='<EFBFBD>';piernad[4][6]='<EFBFBD>';piernad[4][7]='<EFBFBD>';
if (lado==2) {
// Pierna Derecha
for (int f=0,y=17;f<5;f++,y++) {
gotoxy(64,y);
for (int c=0;c<9;c++) {
if (piernad[f][c]=='<EFBFBD>') {
textcolor(9);
cprintf ("%c",piernad[f][c]);
}
else {
textcolor(7);
cprintf ("<EFBFBD>");
}
}
}
}
if (lado==1) {
// Pierna Izquierda.
for (int f=0,y=17;f<5;f++,y++) {
gotoxy(54,y);
for (int c=8;c>=0;c--) {
if (piernad[f][c]=='<EFBFBD>') {
textcolor(9);
cprintf ("%c",piernad[f][c]);
}
else {
textcolor(7);
cprintf ("<EFBFBD>");
}
}
}
}
if (lado==4) {
// Brazo Derecho
for (int f=0,y=12;f<4;f++,y++) {
gotoxy(69,y);
for (int c=0;c<9;c++) {
if (piernad[f][c]=='<EFBFBD>') {
textcolor(9);
cprintf ("%c",piernad[f][c]);
}
else {
textcolor(7);
cprintf ("<EFBFBD>");
}
}
}
}
if (lado==3) {
// Izquierda.
for (int f=0,y=12;f<4;f++,y++) {
gotoxy(49,y);
for (int c=8;c>=0;c--) {
if (piernad[f][c]=='<EFBFBD>') {
textcolor(9);
cprintf ("%c",piernad[f][c]);
}
else {
textcolor(7);
cprintf ("<EFBFBD>");
}
}
}
}
return(0);
}