Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include "iostream"
- #include "conio.h"
- #include "time.h"
- #include "string"
- using namespace std;
- using namespace System;
- bool salir(char texto []);
- void ventana()
- {
- Console::SetWindowSize(149, 40);
- }
- void logo_UPC()
- {
- Console::ForegroundColor = ConsoleColor::DarkRed;
- Console::SetCursorPosition(25, 10); cout << " ## ";
- Console::SetCursorPosition(25, 11); cout << " ,###. ";
- Console::SetCursorPosition(25, 12); cout << " # #####* # ";
- Console::SetCursorPosition(25, 13); cout << " .#/ ####### /#. ";
- Console::SetCursorPosition(25, 14); cout << " ##* #########. *## " << char(186) << " ";
- Console::SetCursorPosition(25, 15); cout << " .### ########### ###. " << char(186) << " ";
- Console::SetCursorPosition(25, 16); cout << " ###( #############( (### " << char(186) << " ## ## ####### ###### ";
- Console::SetCursorPosition(25, 17); cout << "##### #############( ##### " << char(186) << " ## ## ### ### ######## ";
- Console::SetCursorPosition(25, 18); cout << "##### *############# ##### " << char(186) << " ## ## ### ## ### ## ";
- Console::SetCursorPosition(25, 19); cout << "###### ##########. ###### " << char(186) << " ## ## ### ### ## ";
- Console::SetCursorPosition(25, 20); cout << "####### ######## ####### " << char(186) << " ## ## ####### ## ";
- Console::SetCursorPosition(25, 21); cout << "(######## (##### ########( " << char(186) << " ### ### ### ### ## ";
- Console::SetCursorPosition(25, 22); cout << " ########### #### ########## " << char(186) << " ######## ### ######## ";
- Console::SetCursorPosition(25, 23); cout << " ############# (## ############# " << char(186) << " ###### ### ###### ";
- Console::SetCursorPosition(25, 24); cout << " /###########################################/ " << char(186) << " ";
- Console::SetCursorPosition(25, 25); cout << " (########################################( " << char(186) << " ";
- Console::SetCursorPosition(25, 26); cout << " #################################### ";
- Console::SetCursorPosition(25, 27); cout << " (############################( ";
- Console::SetCursorPosition(25, 28); cout << " /###############/ ";
- Console::SetCursorPosition(25, 29); cout << " *######* ";
- system("pause>0");
- //Console::ForegroundColor = ConsoleColor::White;
- }
- void pantalla_carga()
- {
- system("cls");
- int barra;
- Console::ForegroundColor = ConsoleColor::DarkGray;
- Console::SetCursorPosition(32, 7); cout << " .-----------------. .-----------------. ";
- Console::SetCursorPosition(32, 8); cout << " | | | | ";
- Console::SetCursorPosition(32, 9); cout << " | | | * | ";
- Console::SetCursorPosition(32, 10); cout << " | | | | ";
- Console::SetCursorPosition(32, 11); cout << " | * | | | ";
- Console::SetCursorPosition(32, 12); cout << ".-----------------. | | | | .-----------------.";
- Console::SetCursorPosition(32, 13); cout << "| | | | | * | | |";
- Console::SetCursorPosition(32, 14); cout << "| * | | | | | | * * |";
- Console::SetCursorPosition(32, 15); cout << "| | '-----------------' '-----------------' | |";
- Console::SetCursorPosition(32, 16); cout << "| * | | |";
- Console::SetCursorPosition(32, 17); cout << "| | .-----------------. .-----------------. | |";
- Console::SetCursorPosition(32, 18); cout << "| * | | | | | | * * |";
- Console::SetCursorPosition(32, 19); cout << "| | | * * | | * * | | |";
- Console::SetCursorPosition(32, 20); cout << "'-----------------' | | | | '-----------------'";
- Console::SetCursorPosition(32, 21); cout << " | * | | * * | ";
- Console::SetCursorPosition(32, 22); cout << " | | | | ";
- Console::SetCursorPosition(32, 23); cout << " | * * | | * * | ";
- Console::SetCursorPosition(32, 24); cout << " | | | | ";
- Console::SetCursorPosition(32, 25); cout << " '-----------------' '-----------------' ";
- Console::SetCursorPosition(61, 29); printf(". . . C A R G A N D O . . .");
- for (barra = 32; barra < 117; barra++)
- {
- Console::SetCursorPosition(barra, 32); cout << char(177);
- _sleep(13);
- }
- }
- void creditos()
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::Yellow;
- Console::SetCursorPosition(50, 15); cout << "--------------- C R E D I T O S -----------------";
- Console::SetCursorPosition(50, 17); cout << " - UPC CAMPUS SAN MIGUEL ";
- Console::SetCursorPosition(50, 18); cout << " - TRABAJO PARCIAL 2024 ";
- Console::SetCursorPosition(50, 19); cout << " - Programador: Gomez Romero, Adrian Rogers ";
- Console::SetCursorPosition(50, 20); cout << " - Curso: Introduccion a los Algoritmos ";
- Console::SetCursorPosition(50, 21); cout << " - Docente: Mendiolaza Cornejo, Edson Duilio ";
- Console::SetCursorPosition(50, 22); cout << " - Seccion: W1SE ";
- Console::SetCursorPosition(50, 24); cout << "-------------------------------------------------";
- system("pause>0");
- }
- void reglas()
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::Yellow;
- Console::SetCursorPosition(32, 16); cout << "------------------------------------ R E G L A S ------------------------------------";
- Console::SetCursorPosition(32, 18); cout << " - El jugador debe de lanzar los dados. ";
- Console::SetCursorPosition(32, 19); cout << " - Si al lanzar los dados obtiene un 4, 5, 6, 9, o un 10 puede seguir jugando. ";
- Console::SetCursorPosition(32, 20); cout << " - Si al lanzar los dados obtiene un 2, 3, o un 12 el jugador pierde la partida. ";
- Console::SetCursorPosition(32, 21); cout << " - El jugador gana la partida si obtiene un 7 o un 11. ";
- Console::SetCursorPosition(32, 23); cout << "-------------------------------------------------------------------------------------";
- system("pause>0");
- }
- char dadogif[][100] = {
- " # ",
- " ## ## ",
- " ## ## ",
- " ## ## ",
- " ## ## ",
- "# * #",
- " ## ## ",
- " ## ## ",
- " ## ## ",
- " ## ## ",
- " # "
- };
- char dadogif2[][100] = {
- " # ",
- " #### # ",
- " #### # ",
- "# # ",
- " # # ",
- " # * # ",
- " # # ",
- " # # ",
- " # #### ",
- " # #### ",
- " # "
- };
- char dadogif3[][100] = {
- " ",
- " ",
- " ",
- " ",
- " ",
- " * ",
- " ",
- " ",
- " ",
- " ",
- " "
- };
- void animar() {
- for (int i = 0; i < 11; i++) {
- Console::SetCursorPosition(50, 4 + i);
- cout << dadogif[i];
- }
- _sleep(100);
- for (int i = 0; i < 11; i++) {
- Console::SetCursorPosition(50, 4 + i);
- cout << dadogif2[i];
- }
- }
- void dados(int dado, int x, int y) {
- Console::SetCursorPosition(x, y);
- switch (dado) {
- case 1:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- case 2:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- case 3:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- case 4:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- case 5:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| * |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- case 6:
- cout << ".-----------------.";
- Console::SetCursorPosition(x, y + 1);
- cout << "| |";
- Console::SetCursorPosition(x, y + 2);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 3);
- cout << "| |";
- Console::SetCursorPosition(x, y + 4);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 5);
- cout << "| |";
- Console::SetCursorPosition(x, y + 6);
- cout << "| * * |";
- Console::SetCursorPosition(x, y + 7);
- cout << "| |";
- Console::SetCursorPosition(x, y + 8);
- cout << "'-----------------'";
- break;
- }
- }
- void gana_partida(int resultadoganado)
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::DarkCyan;
- Console::SetCursorPosition(11, 11); cout << "######## ######## ### ###### ###### ###### ###### #### ###### ######## ####### #####";
- Console::SetCursorPosition(11, 12); cout << "######## ######## ### ######## ######## ######## ####### ###### ####### ######## ####### #####";
- Console::SetCursorPosition(11, 13); cout << "### ### ### #### ### ## #### ## ### ### ### ## ### ### ### #####";
- Console::SetCursorPosition(11, 14); cout << "######## ######## ### #### ## #### ## ## ### ### ## ## ######## ###### ### ";
- Console::SetCursorPosition(11, 15); cout << "######## ######## ### #### ## #### ## ## ### ### ## ## ######## ###### # ";
- Console::SetCursorPosition(11, 16); cout << "### ### ### #### ### ## #### ## ### ######## ## ### ### ### ### ";
- Console::SetCursorPosition(11, 17); cout << "### ######## ######## ###### ######## ######## ####### ### ### ####### ######## ####### #####";
- Console::SetCursorPosition(11, 18); cout << "### ######## ######## ###### ###### ###### ###### ## ## ###### ######## ####### ### ";
- Console::SetCursorPosition(11, 21); cout << " ## ## #### ####### ###### #### ## ## #### ###### ###### ";
- Console::SetCursorPosition(11, 22); cout << " ### ### ###### ####### ######## ###### ### ## ###### ####### ### ### ";
- Console::SetCursorPosition(11, 23); cout << " ### ### ### ### ### ### ### ### #### ## ### ### ## ### ### ### ";
- Console::SetCursorPosition(11, 24); cout << " ######## ### ### ###### ## ### ### ### ##### ## ### ### ## ## ## ## ";
- Console::SetCursorPosition(11, 25); cout << " ######## ### ### ###### ## ## ### ### ## ##### ### ### ## ## ## ## ";
- Console::SetCursorPosition(11, 26); cout << " ### ### ######## ### ### ### ######## ## #### ######## ## ### ### ### ";
- Console::SetCursorPosition(11, 27); cout << " ### ### ### ### ####### ######## ### ### ## ### ### ### ####### ######## ";
- Console::SetCursorPosition(11, 28); cout << " ## ## ## ## ####### ###### ## ## ## ## ## ## ###### ###### ";
- Console::SetCursorPosition(58, 35); cout << "Ganaste porque salio un " << resultadoganado << ".";
- }
- void pierde_partida(int resultadoperdido)
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::DarkMagenta;
- Console::SetCursorPosition(14, 11); cout << " ###### ## ## ######## ### #### ####### ######## ###### ### ### #### #####";
- Console::SetCursorPosition(14, 12); cout << "######## ## ## ######## ### ###### ####### ######## ######## ######## ###### #####";
- Console::SetCursorPosition(14, 13); cout << "### ### ## ## ### ### ### ### ### # ## # #### ######## ### ### #####";
- Console::SetCursorPosition(14, 14); cout << "### ### ## ## ######## ### ### ### ###### ## #### ### ### ### ### ### ";
- Console::SetCursorPosition(14, 15); cout << "### ### ## ## ######## ### ### ### ###### ## #### ### ### ### ### # ";
- Console::SetCursorPosition(14, 16); cout << "######## ### ### ### ### ######## ### ## #### ### ### ######## ### ";
- Console::SetCursorPosition(14, 17); cout << " ###### ######## ######## ######## ### ### ####### ## ###### ### ### ### ### #####";
- Console::SetCursorPosition(14, 18); cout << " ##### ###### ######## ######## ## ## ####### ## ###### ## ## ## ## ### ";
- Console::SetCursorPosition(14, 21); cout << " ## ## #### ####### ####### ######## ####### ###### ###### ###### ###### ";
- Console::SetCursorPosition(14, 22); cout << " ### ### ###### ####### ### ### ######## ### ### ####### ######## ####### ### ### ";
- Console::SetCursorPosition(14, 23); cout << " ### ### ### ### ### ### ## ### ### ## ## ### #### ## ### ### ### ";
- Console::SetCursorPosition(14, 24); cout << " ######## ### ### ###### ### ### ######## ### ### ## ## #### ## ## ## ## ";
- Console::SetCursorPosition(14, 25); cout << " ######## ### ### ###### ####### ######## ####### ## ## #### ## ## ## ## ";
- Console::SetCursorPosition(14, 26); cout << " ### ### ######## ### ### ### ### ### ## ### #### ## ### ### ### ";
- Console::SetCursorPosition(14, 27); cout << " ### ### ### ### ####### ### ######## ### ### ####### ###### ####### ######## ";
- Console::SetCursorPosition(14, 28); cout << " ## ## ## ## ####### ### ######## ### ### ###### ###### ###### ###### ";
- Console::SetCursorPosition(58, 35); cout << "Perdiste porque salio un " << resultadoperdido << ".";
- }
- void dibujar_bordes()
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::White;
- Console::SetCursorPosition(1, 1);
- for (int i = 1; i <= 147; i++)
- {
- Console::SetCursorPosition(i, 1); cout << char(219);
- Console::SetCursorPosition(i, 38); cout << char(219);
- }
- for (int j = 1; j <= 38; j++)
- {
- Console::SetCursorPosition(1, j); cout << char(219);
- Console::SetCursorPosition(147, j); cout << char(219);
- }
- }
- void tirar_dados(int& dado1, int& dado2)
- {
- dado1 = rand() % 6 + 1;
- dado2 = rand() % 6 + 1;
- }
- string verificar_resultado(int total)
- {
- if (total == 7 || total == 11) {
- return "ganar";
- }
- else if (total == 2 || total == 3 || total == 12) {
- return "perder";
- }
- else {
- return "continuar";
- }
- }
- void juego()
- {
- int dado1, dado2;
- int suma;
- string resultado;
- system("cls");
- dibujar_bordes();
- Console::SetCursorPosition(3, 3); cout << "###### ### ### ###### #### ###### ##### ### ###### ### ##### ## ## ###### ##### ##### ";
- Console::SetCursorPosition(3, 4); cout << "###### ####### ### ### ###### ###### ####### ##### ###### ### ####### ### ### ###### ####### ### ###";
- Console::SetCursorPosition(3, 5); cout << "## ####### ### ## ### ## ### ### ### ## ### ### ### ### ## ### ### ###";
- Console::SetCursorPosition(3, 6); cout << "###### ## ## ### ### ### ###### ### ### ### ###### ### ## ## ### ###### ## ### ## ##";
- Console::SetCursorPosition(3, 7); cout << "##### ### ### ###### ### ##### ####### ### ### ##### ### ### ### ## ##### ## ## ## ##";
- Console::SetCursorPosition(3, 8); cout << "### ### ### ### ### ## ### ####### ## ### ### ## #### ### ### ### ### ### ### ###";
- Console::SetCursorPosition(3, 9); cout << "####### ## ## ### ##### ###### ####### ### ### ####### ####### ####### ####### ###### ####### #######";
- Console::SetCursorPosition(3, 10); cout << "##### ## ## ### ##### ##### ###### ## ## ##### ##### ##### ##### ###### ###### ##### ";
- Console::SetCursorPosition(3, 14); cout << "Presiona cualquier tecla para lanzar los dados...";
- getch();
- do
- {
- tirar_dados(dado1, dado2);
- suma = dado1 + dado2;
- for (int i = 0; i < 3; i++) animar();
- Console::SetCursorPosition(3, 17); cout << "Resultado del lanzamiento:";
- dados(dado1, 14, 20);
- dados(dado2, 54, 20);
- Console::SetCursorPosition(90, 17); cout << "Suma: " << suma << " ";
- resultado = verificar_resultado(suma);
- if (resultado == "ganar")
- {
- getch();
- gana_partida(suma);
- getch();
- }
- else if (resultado == "perder")
- {
- getch();
- pierde_partida(suma);
- getch();
- }
- else {
- Console::SetCursorPosition(3, 32); cout << "Sigue jugando...";
- Console::SetCursorPosition(3, 34); cout << "Presiona cualquier tecla para lanzar de nuevo.";
- getch();
- }
- } while (resultado == "continuar");
- }
- void despedida()
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::DarkGreen;
- Console::SetCursorPosition(18, 11); cout << " ###### ####### #### ###### ###### #### ####### ####### ###### ####### ";
- Console::SetCursorPosition(18, 12); cout << "######## ### ### ###### ######## ######## ###### ####### ### ### ### ### ### ###";
- Console::SetCursorPosition(18, 13); cout << "### ### ## ### ### ### ## #### ### ### ### ### ## ### ### ### ##";
- Console::SetCursorPosition(18, 14); cout << "## ### ### ### ### ### ## #### ### ### ###### ### ### ## ## ### ###";
- Console::SetCursorPosition(18, 15); cout << "## ## ####### ### ### ## #### ### ### ###### ####### ## ## ####### ";
- Console::SetCursorPosition(18, 16); cout << "### ### ### ### ######## ### ## #### ######## ### ### ### ### ### ###";
- Console::SetCursorPosition(18, 17); cout << "######## ### ### ### ### ######## ###### ### ### ####### ### ######## ### ###";
- Console::SetCursorPosition(18, 18); cout << " ###### ### ### ## ## ###### ###### ## ## ####### ### ###### ### ###";
- Console::SetCursorPosition(18, 21); cout << " ######## ## ## ###### #### ####### ";
- Console::SetCursorPosition(18, 22); cout << " ######## ## ## ######## ###### ### ### ";
- Console::SetCursorPosition(18, 23); cout << " ### ## ## ### ### ### ### ## ";
- Console::SetCursorPosition(18, 24); cout << " ### ## ## ## ### ### ### ### ### ";
- Console::SetCursorPosition(18, 25); cout << " ### ## ## ## ## ### ### ####### ";
- Console::SetCursorPosition(18, 26); cout << " ## ### ### ### ### ### ######## ### ### ";
- Console::SetCursorPosition(18, 27); cout << " ######## ######## ######## ### ### ### ### ";
- Console::SetCursorPosition(18, 28); cout << " ###### ###### ###### ## ## ### ### ";
- system("pause>0");
- exit(0);
- }
- bool salir(char texto [])
- {
- char confirmar;
- do
- {
- Console::SetCursorPosition(58, 35); cout << "¨Estas seguro de que deseas " << texto << "?";
- Console::SetCursorPosition(58, 37); cout << " [Y] SI [N] NO ";
- confirmar = _getch();
- switch (confirmar)
- {
- case 'y':
- return true;
- case 'n':
- return false;
- }
- } while (1);
- }
- void menu() {
- int opcion = 0;
- do
- {
- system("cls");
- Console::ForegroundColor = ConsoleColor::DarkYellow;
- Console::SetCursorPosition(48, 11); cout << " ###### ####### #### ####### ####### ";
- Console::SetCursorPosition(48, 12); cout << " ######## ### ### ###### ### ### ####### ";
- Console::SetCursorPosition(48, 13); cout << " ### ## ### ## ### ### ### ## #### ";
- Console::SetCursorPosition(48, 14); cout << " ### ## ### ## ### ### ### ## ### ";
- Console::SetCursorPosition(48, 15); cout << " ## ### ## ### ### ### ## #### ";
- Console::SetCursorPosition(48, 16); cout << " ## ### ## ### ### ### ## #### ";
- Console::SetCursorPosition(48, 17); cout << " ## ### ### ### ### ### ### #### ";
- Console::SetCursorPosition(48, 18); cout << " ## ####### ### ### ####### #### ";
- Console::SetCursorPosition(48, 19); cout << " ## ### ### ### ### ### #### ";
- Console::SetCursorPosition(48, 20); cout << " ### ## ### ### ######## ### ### ";
- Console::SetCursorPosition(48, 21); cout << " ### ## ### ### ### ### ### #### ";
- Console::SetCursorPosition(48, 22); cout << " ######## ### ### ### ### ### ####### ";
- Console::SetCursorPosition(48, 23); cout << " ###### ### ### ## ## ### ####### ";
- Console::ForegroundColor = ConsoleColor::White;
- Console::SetCursorPosition(48, 24); cout << "______________________________________________________";
- Console::SetCursorPosition(48, 26); cout << "------------------------------------------------------";
- Console::ForegroundColor = ConsoleColor::Cyan;
- Console::SetCursorPosition(49, 28); cout << "[1] JUGAR [2] REGLAS [3] CREDITOS [0] SALIR";
- char tecla = 45;
- do
- {
- if (_kbhit()) {
- tecla = _getch();
- switch (tecla)
- {
- case 49:
- opcion = 1;
- break;
- case 50:
- opcion = 2;
- break;
- case 51:
- opcion = 3;
- break;
- case 48:
- opcion = 0;
- break;
- }
- }
- } while (tecla < 48 || tecla > 51);
- switch (opcion)
- {
- case 1:
- juego();
- break;
- case 2:
- reglas();
- break;
- case 3:
- creditos();
- break;
- case 0:
- if (salir("salir")) {
- despedida();
- exit(0);
- }
- break;
- default:
- break;
- }
- } while (!(opcion == 1));
- }
- int main()
- {
- srand(time(0));
- Console::CursorVisible = false;
- ventana();
- logo_UPC();
- pantalla_carga();
- while (true)
- {
- menu();
- system("pause>0");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement