hey Vicious i tried this and works really well:
Code:
#include <allegro.h>
int counter;
int x = 300, left = 0, right = 0;
void update_counter()
{
counter++;
}
END_OF_FUNCTION(update_counter);
int main()
{
allegro_init();
install_keyboard();
LOCK_VARIABLE(counter);
LOCK_FUNCTION(update_counter);
install_int_ex( update_counter, BPS_TO_TIMER(60));
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 640, 480, 0, 0);
BITMAP *ship = load_bitmap( "ship.bmp", NULL );
draw_sprite ( screen, ship, x, 300 );
while ( !key[KEY_ESC] )
{
while (counter > 0) {
if (left) x-=5;
if (right) x+=5;
counter--;
}
if ( x < 540 && key[KEY_RIGHT])
right = 1;
else
right = 0;
if ( x > 50 && key[KEY_LEFT])
left = 1;
else
left = 0;
vsync();
clear_to_color (screen, 0);
draw_sprite ( screen, ship, x, 300 );
}
destroy_bitmap(ship);
allegro_exit();
return 0;
}
END_OF_MAIN();
the only problem is that it messes up a tiny bit at the beginning and it leaves a trail once you move the bmp. however, there isn't any flickering at all right after the beginning.