You are on page 1of 2

#include <allegro.

h>
int numeroAdivinar, numeroTecleado;
char tecla1, tecla2;
int acertado;
int intentos;
int lineaEscritura;
#define MAXIMONUMERO 99
#define NUMEROINTENTOS 6

int main()
{
allegro_init();
install_keyboard();
if (set_gfx_mode(GFX_SAFE,320,200,0,0)!=0){
set_gfx_mode(GFX_TEXT,0,0,0,0);
allegro_message(
"Incapaz de entrar a modo grafico\n%s\n",
allegro_error);
return 1;
}
intentos = 0;
lineaEscritura = 50;
srand(time(0));
numeroAdivinar = rand() % MAXIMONUMERO;
acertado = 0;
textout(screen, font, "Adivina el Numero", 10,10,
palette_color[14]);
do {
textout(screen, font, "Teclea dos cifras (00 a 99)", 15,lineaEscritura,
palette_color[13]);
tecla1 = readkey();
textprintf(screen, font, 235,lineaEscritura,

palette_color[13], "%c", tecla1);


tecla2 = readkey();
textprintf(screen, font, 243,lineaEscritura,
palette_color[13], "%c", tecla2);
numeroTecleado = (int) (tecla1 - '0') * 10
+ tecla2 - '0';
if (numeroTecleado == numeroAdivinar) acertado = 1;
else if (numeroTecleado < numeroAdivinar)
textout(screen, font, "Corto", 260,lineaEscritura,
palette_color[12]);
else if (numeroTecleado > numeroAdivinar)
textout(screen, font, "Grande", 260,lineaEscritura,
palette_color[12]);
intentos++;
lineaEscritura += 10;
} while( (!acertado) && (intentos < NUMEROINTENTOS));
if (acertado)
textout(screen, font, "Felicidades Acertaste!!!", 160,180,
palette_color[15]);
else
textprintf(screen, font, 160,180,
palette_color[15], "Lo siento Era: %d", numeroAdivinar);

readkey();
}
END_OF_MAIN();

You might also like