Ver Mensaje Individual
  #6 (permalink)  
Antiguo 26/05/2015, 16:59
Avatar de Jose_A
Jose_A
 
Fecha de Ingreso: mayo-2015
Ubicación: México, Sonora.
Mensajes: 180
Antigüedad: 9 años
Puntos: 0
Respuesta: Unión de dos menús o programas

Si, yo tampoco tengo ni la menor idea de como hacerlo. Intente pasarlo de la ventana de Allegro al cmd, y despues que me lo pasara de nuevo para Allegro con un goto game, algo asi:

Cita:
#include <stdio.h>
#include <allegro.h>
#include <cstdlib>
#include <iostream>
#include <time.h>

using namespace std;

#define AZUL 0x1AA9D1
#define GRIS 0x445051
#define BLANCO 0xFFFFFF



inline void iniciarSistemas(int ANCHO, int ALTO){
allegro_init(); //Inicia la librería Allegro
install_keyboard(); //Instala el controlador de teclado de Allegro
set_color_depth(32); //Establece el formato de píxel para ser utilizado.
set_gfx_mode(GFX_AUTODETECT_WINDOWED, ANCHO, ALTO, 0, 0); //Pixeles utilizados
install_mouse(); // Para usar el ratón
}



int main() {

iniciarSistemas(800, 531);
game:
BITMAP *buffer = create_bitmap ( 800, 531 );
BITMAP *cursor = load_bitmap ( "cursor.bmp", NULL );
//escena1
BITMAP *escena1Fondo = load_bitmap ( "escena1fondo.bmp", NULL );
BITMAP *escena1Jugar = load_bitmap ( "escena1jugar.bmp", NULL );
BITMAP *escena1Salir = load_bitmap ( "escena1salir.bmp", NULL );
//otras escenas
BITMAP *menu = load_bitmap ( "menu.bmp", NULL );
BITMAP *instrucciones = load_bitmap ( "instrucciones1.bmp", NULL );
BITMAP *creditos = load_bitmap ( "creditos1.bmp", NULL );

if (buffer == NULL || escena1Fondo == NULL || escena1Jugar == NULL || escena1Salir == NULL ||
menu == NULL || instrucciones == NULL || creditos == NULL || cursor == NULL ) {
cout << "ERROR al cargar alguna de las imagenes" << endl;
destroy_bitmap ( buffer );
destroy_bitmap ( cursor );
destroy_bitmap ( escena1Fondo );
destroy_bitmap ( escena1Jugar );
destroy_bitmap ( escena1Salir );
destroy_bitmap ( menu );
destroy_bitmap ( instrucciones);
destroy_bitmap ( creditos );
return 1;
}
clear_to_color ( buffer, 0x000000 );

int tiempo_ticks = 0;
int ticks = CLOCKS_PER_SEC / 20;
int op = 0;
int sb = 0;
int escena = 1; //escena inicial
int salida = false;

while ( !salida ) {
if ( clock() > tiempo_ticks + ticks ) {
tiempo_ticks = clock();

clear_to_color ( buffer, 0x000000 );

switch ( escena ) {
case 1: //Fondo inicial
if ( mouse_x > 176 && mouse_x < 326 && mouse_y > 410 && mouse_y < 485 ) {
blit ( escena1Jugar, buffer, 0, 0, 0, 0, 800, 531 );

if ( mouse_b & 1 ) {
escena = 2; //pasa al menú
}
} else if ( mouse_x > 472 & mouse_x < 619 && mouse_y > 412 & mouse_y < 483 ) {
blit ( escena1Salir, buffer, 0, 0, 0, 0, 800, 531 );
if ( mouse_b & 1 ) {
salida = true;
}

} else {
blit ( escena1Fondo, buffer, 0, 0, 0, 0, 800, 531 ); // Si no se cumple lo anterior queda el fondo 1
}
masked_blit ( cursor, buffer, 0, 0, mouse_x, mouse_y, 13, 22 ); //Para colocar transparencia al cursor, se imprime en el buffer con las cordenadas del mouse.

break;
case 2: //escena2

//Controla el movimiento de arriba abajo del menu
if ( !key[KEY_UP] && !key[KEY_DOWN] && sb == 1 ) {sb = 0;}
if ( key[KEY_UP] && sb == 0 ) { op--; if ( op == 0 ) op = 5; sb = 1; }
if ( key[KEY_DOWN] && sb == 0 ) { op++; if ( op == 6 ) op = 1; sb = 1; }


if ( op == 1 && key[KEY_ENTER] ) salida=true;
if ( op == 2 && key[KEY_ENTER] ) { escena = 6; }
if ( op == 3 && key[KEY_ENTER] ) { escena = 3; }


//{ escena = 3; }
if ( op == 4 && key[KEY_ENTER] ) { escena = 4; }
if ( op == 5 && key[KEY_ENTER] ) { escena = 1; }

blit ( menu, buffer, 0, 0, 0, 0, 800, 531 );

//Animacion de las letras del menu
if ( op == 1 ) { textout_centre_ex ( buffer, font, "Nueva Partida" , 390, 260, AZUL, GRIS );
} else { textout_centre_ex ( buffer, font, "Nueva Partida" , 390, 260, BLANCO, GRIS ); }
if ( op == 2 ) { textout_centre_ex ( buffer, font, "Niveles" , 385, 318, AZUL, GRIS );
} else { textout_centre_ex ( buffer, font, "Niveles" , 385, 318, BLANCO, GRIS ); }
if ( op == 3 ) { textout_centre_ex ( buffer, font, "Instrucciones" , 390, 368, AZUL, GRIS );
} else { textout_centre_ex ( buffer, font, "Instrucciones" , 390, 368, BLANCO, GRIS ); }
if ( op == 4 ) { textout_centre_ex ( buffer, font, "Creditos" , 380, 417, AZUL, GRIS );
} else { textout_centre_ex ( buffer, font, "Creditos" , 380, 417, BLANCO, GRIS ); }
if ( op == 5 ) { textout_centre_ex ( buffer, font, "Volver" , 381, 467, AZUL, GRIS );
} else { textout_centre_ex ( buffer, font, "Volver" , 381, 467, BLANCO, GRIS ); }
break;
case 3:
if ( key[KEY_ESC] ) {escena = 2; }
blit ( instrucciones, buffer, 0, 0, 0, 0, 800, 531 );
break;
case 4:
if ( key[KEY_ESC] ) {escena = 2; }
blit ( creditos, buffer, 0, 0, 0, 0, 800, 531 );
break;
case 5:
if ( key[KEY_ESC] ) {escena = 2; }
textout_centre_ex ( buffer, font, "Aqui va el juego :3" , 390, 260, AZUL, GRIS);
break;
case 6:
if ( key[KEY_ESC] ) {escena = 2; }
textout_centre_ex ( buffer, font, "Aqui van los niveles :3" , 390, 260, AZUL, GRIS);
break;
default:
break;
}

blit ( buffer, screen, 0, 0, 0, 0, 800, 531 );
}

}



cout << "Aqui pasa el codigo" << endl;
if ( key[KEY_A] ) { goto game; }

destroy_bitmap ( buffer );
destroy_bitmap ( cursor );
destroy_bitmap ( escena1Fondo );
destroy_bitmap ( escena1Jugar );
destroy_bitmap ( escena1Salir );
destroy_bitmap ( menu );
destroy_bitmap ( instrucciones);
destroy_bitmap ( creditos);

return 0;

}

END_OF_MAIN();
Que al dar la tecla A me mande de nuevo al menu, pero no funciona....queria que el codigo apareciera en el cmd y ya despues pasarlo al menu pero es tooodooo un desastre y ya no se que haceeer xDDD rayosss ;s