why dose the down key not work after i press enter.Code:int allegro ( int srcx, int srcy )
{
allegro_init();
install_keyboard();
install_timer()
LOCK_VARIABLE ( speed_counter );
LOCK_FUNCTION ( increment_speed_counter )
install_int_ex ( increment_speed_counter, BPS_TO_TIMER ( 70 ) );//Set beat's per second 60 works well, generally.
set_color_depth ( 32 );
set_gfx_mode ( GFX_AUTODETECT,srcx,srcy,0,0 );
BITMAP *BG = NULL;
BITMAP *ALLO = NULL;
BITMAP *arrow = NULL;
ALLO = load_bitmap ( "./allgero.bmp", NULL );
BG = load_bitmap ( "./back.bmp", NULL );
arrow = load_bitmap ( "./arrow.bmp", NULL );
buffer = create_bitmap ( srcx,srcy );
if ( BG == NULL )
{
set_gfx_mode ( GFX_TEXT,0,0,0,0 ); //Set the screen mode for allegro messages
allegro_message ( "Could not load back.bmp" );
exit ( EXIT_FAILURE );
}
if ( ALLO == NULL )
{
set_gfx_mode ( GFX_TEXT,0,0,0,0 ); //Set the screen mode for allegro messages
allegro_message ( "Could not load allgero.bmp" );
exit ( EXIT_FAILURE );
}
if ( arrow == NULL )
{
set_gfx_mode ( GFX_TEXT,0,0,0,0 ); //Set the screen mode for allegro messages
allegro_message ( "Could not load arrow.bmp" );
exit ( EXIT_FAILURE );
}
short ran_before1 = 0;
short ran_before = 0;
short ran_before2 = 0;
short ran_before3 = 0;
short ran_before4 = 0;
int xx = srcx/2-400;
int yy = srcy/2-300;
long buttony = 0;
int aa = -1;
int buttonx = 1;
/*int arrow_bb_left = xx;
int arrow_bb_top = yy;
int arrow_bb_bottom = ( arrow_bb_top + arrow->h );
int arrow_bb_right = ( arrow_bb_left + arrow->w );
int ALLO_bb_left = xxa;
int ALLO_bb_top = yya;
int ALLO_bb_right = ( ALLO_bb_left + ALLO->w );
int ALLO_bb_bottom = ( ALLO_bb_top + ALLO->h );*/
//int show_bbox = FALSE;
//int collision = FALSE;
char str[50];
char NUMBER1[100]="0";
char NUMBER[100]="0 0 0 00 0 ";
while ( !key[KEY_ESC] )
{
while ( speed_counter > 0 )
{
//collision = FALSE;
//if ( arrow_bb_top < ALLO_bb_top||arrow_bb_bottom > ALLO_bb_bottom||arrow_bb_right > ALLO_bb_right||arrow_bb_left < ALLO_bb_left )
//{
// collision = TRUE;
//}
if ( key[KEY_UP]&&ran_before == 0&&buttony!=0 )
{
ran_before = 1;
buttony=buttony-1;
}
if ( !key[KEY_UP]&&ran_before == 1 )
{
ran_before = 0;
}
if ( key[KEY_DOWN]&&ran_before1 == 0)
{
cout<<"KEY_DOWN";
ran_before1 = 1;
buttony++;
}
if ( !key[KEY_DOWN]&&ran_before1 == 1 )
{
cout<<"!KEY_DOWN";
ran_before1 = 0;
}
if ( key[KEY_RIGHT]&&ran_before2 == 0&&buttonx!=2 )
{
buttonx++;
ran_before2 = 1;
}
if ( !key[KEY_RIGHT]&&ran_before2 == 1 )
{
ran_before2 = 0;
}
if ( key[KEY_LEFT]&&ran_before3 == 0&&buttonx!=0 )
{
buttonx--;
ran_before3 = 1;
}
if ( !key[KEY_LEFT]&&ran_before3 == 1 )
{
ran_before3 = 0;
}
if ( key[KEY_W] )
{
yy--;
}
if ( key[KEY_A] )
{
xx--;
}
if ( key[KEY_S] )
{
yy++;
}
if ( key[KEY_D] )
{
xx++;
}
if ( key[KEY_R] )
{
xx = srcx/2-400;
yy = srcy/2-300;
}
if ( key[KEY_ENTER]&&buttony == 3&&buttonx == 1&&ran_before4 == 0 )
{
buttony = 0;
buttonx = 0;
settings ( BG,ALLO,xx,yy,srcx,srcy );
ran_before4 = 1;
}
if ( key[KEY_ENTER]&&buttony == 0&&buttonx == 0&&ran_before4 == 0 )
{
sprintf (NUMBER1, "%d",1);
NUMBER[aa]=NUMBER1[0];
aa++;
ran_before4 = 1;
}
if ( key[KEY_ENTER]&&buttony == 0&&buttonx == 1&&ran_before4 == 0 )
{
sprintf (NUMBER1, "%d",2);
NUMBER[aa]=NUMBER1[0];
aa++;
ran_before4 = 1;
}
if ( key[KEY_ENTER]&&buttony == 0&&buttonx == 2&&ran_before4 == 0 )
{
sprintf (NUMBER1, "%d",3);
NUMBER[aa]=NUMBER1[0];
aa++;
ran_before4 = 1;
}
if ( key[KEY_ENTER]&&buttony == 1&&buttonx == 0&&ran_before4 == 0 )
{
sprintf (NUMBER1, "%d",4);
NUMBER[aa]=NUMBER1[0];
aa++;
ran_before4 = 1;
}
if ( key[KEY_ENTER]&&buttony == 2&&buttonx == 0&&ran_before4 == 0 )
{
sprintf (NUMBER1, "%d",5);
NUMBER[aa]=NUMBER1[0];
aa++;
NUMBER[aa]='\0';
ran_before4 = 1;
}
if ( !key[KEY_ENTER]&&ran_before4 == 1 )
{
ran_before4 = 0;
}
/*arrow_bb_left = xx;
arrow_bb_top = yy;
arrow_bb_bottom = ( arrow_bb_top + arrow->h );
arrow_bb_right = ( arrow_bb_left + arrow->w );
ALLO_bb_left = xxa;
ALLO_bb_top = yya;
ALLO_bb_right = ( ALLO_bb_left + ALLO->w );
ALLO_bb_bottom = ( ALLO_bb_top + ALLO->h );*/
sprintf (str, "%d,%d,%d",xx,yy,aa);
speed_counter--;
}
blit ( BG, buffer, 0,0,0,0,srcx,srcy );
masked_blit ( ALLO, buffer, 0,0,xx,yy,800,600 );
draw_button ( 400-64+xx,300-128+yy, 0, "2" );
draw_button ( 400-64+xx,300-54+yy, 0, "5" );
draw_button ( 400-64+xx,320+yy, 0, "8" );
draw_button ( 400-64+xx,394+yy, 0, "Settings" );
draw_button ( 400-202+xx,300-128+yy, 0, "1" );
draw_button ( 400-202+xx,300-54+yy, 0, "4" );
draw_button ( 400-202+xx,320+yy, 0, "7" );
draw_button ( 474+xx,300-128+yy, 0, "3" );
draw_button ( 474+xx,300-54+yy, 0, "6" );
draw_button ( 474+xx,320+yy, 0, "9" );
draw_button ( 474+xx,394+yy, 0, "0" );
draw_rectangle ( 200+xx,75+yy,600+xx,120+yy,0,0,0 );
if ( buttony == 0&&buttonx == 1 )
{
draw_button ( 400-64+xx,300-128+yy, 1, "2" );
}
if ( buttony == 1&&buttonx == 1 )
{
draw_button ( 400-64+xx,300-54+yy, 1, "5" );
}
if ( buttony == 2&&buttonx == 1 )
{
draw_button ( 400-64+xx,300+20+yy, 1, "8" );
}
if ( buttony == 3&&buttonx == 1 )
{
draw_button ( 400-64+xx,300+94+yy, 1, "Settings" );
}
if ( buttony == 0&&buttonx == 0 )
{
draw_button ( 400-202+xx,300-128+yy, 1, "1" );
}
if ( buttony == 1&&buttonx == 0 )
{
draw_button ( 400-202+xx,300-54+yy, 1, "4" );
}
if ( buttony == 2&&buttonx == 0 )
{
draw_button ( 400-202+xx,300+20+yy, 1, "7" );
}
if ( buttony == 0&&buttonx == 2 )
{
draw_button ( 474+xx,300-128+yy, 1, "3" );
}
if ( buttony == 1&&buttonx == 2 )
{
draw_button ( 474+xx,300-54+yy, 1, "6" );
}
if ( buttony == 2&&buttonx == 2 )
{
draw_button ( 400+74+xx,300+20+yy, 1, "9" );
}
if ( buttony == 3&&buttonx == 2 )
{
draw_button ( 474+xx,394+yy, 1, "0" );
}
textprintf_ex ( buffer, font,0 , 0, makecol ( 0,0,0 ), -1, str );
textprintf_ex ( buffer, font,xx+100 , yy+80, makecol ( 0,0,0 ), -1, NUMBER);
textprintf_ex ( buffer, font,200 , 200, makecol ( 0,0,0 ), -1, NUMBER1);
blit ( buffer, screen, 0,0,0,0,srcx,srcy );
}
destroy_bitmap ( ALLO );
destroy_bitmap ( BG );
destroy_bitmap ( arrow );
return 0;
}
thanks in advanced, sorry for the question i cant seem to figure it out myself, im still a noob.