Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/06/2013, 15:33
karma274
 
Fecha de Ingreso: septiembre-2012
Ubicación: Norte de Santander
Mensajes: 127
Antigüedad: 12 años
Puntos: 1
Respuesta: Problemas con textout y textprintf

Posteare todo el codigo de esta manera supongo te podras
orientar mejor, debi hacerlo desde el principio..lol

Código C++:
Ver original
  1. #include <allegro.h>
  2. int numeroAdivinar, numeroTecleado;
  3. char tecla1, tecla2;
  4. int acertado;
  5. int intentos;
  6. int lineaEscritura;
  7.  
  8. #define MAXIMONUMERO 99
  9. #define NUMEROINTENTOS 6
  10.  
  11. int main(){
  12.     allegro_init();
  13.     install_keyboard();
  14.    
  15.     if(set_gfx_mode(GFX_SAFE, 320, 200, 0, 0)!=0){
  16.        set_gfx_mode(GFX_TEXT,0,0,0,0);
  17.        allegro_message(
  18.          "Incapaz de entrar en modo grafico\n%s\n",
  19.          allegro_error);
  20.        return 1;
  21.     }
  22.    
  23.     intentos = 0;
  24.     lineaEscritura = 50;
  25.    
  26.     srand(time(0));
  27.     numeroAdivinar = rand() % MAXIMONUMERO;
  28.     acertado = 0;
  29.    
  30.     textout_ex(screen, font, "Adivinar numeros", 10,10,0xff0000, -1);
  31.    
  32.     do{
  33.        
  34.     textout_ex(screen, font, "Teclea dos cifras (00 a 99)", 15,lineaEscritura, palette_color[13]);
  35.    
  36.     tecla1 = readkey();
  37.     textprintf_ex(screen, font, 235, lineaEscritura, palette_color[13], "%c", tecla1);
  38.  
  39.     tecla2 = readkey();
  40.     textprintf_ex(screen, font, 243, lineaEscritura, palette_color[13], "%c", tecla2);
  41.    
  42.     numeroTecleado = (int) (tecla1 - '0') * 10 + tecla2 - '0';
  43.    
  44.     if (numeroTecleado == numeroAdivinar) acertado = 1;
  45.       else if (numeroTecleado < numeroAdivinar)
  46.     textout_ex(screen, font, "Corto", 260,lineaEscritura, palette_color[12]);
  47.       else if(numeroTecleado > numeroAdivinar)
  48.     textout_ex(screen, font, "Grande", 260,lineaEscritura, palette_color[12]);
  49.    
  50.     intentos++;
  51.     lineaEscritura += 10;
  52.    
  53.     }while((!acertado) && (intentos < NUMEROINTENTOS));
  54.    
  55.     if (acertado)
  56.     textout_ex(screen, font, "Acertaste!!!",160,180,palette_color[15]);
  57.     else
  58.     textprintf_ex(screen, font, 160, 180, palette_color[15], "Era: %d",numeroAdivinar);
  59.    
  60.     readkey();
  61. }
  62.  
  63. END_OF_MAIN();