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 );
BITMAP *buffer = create_bitmap( 640, 480 );
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;
draw_sprite ( screen, ship, x, 400 );
clear_bitmap( buffer); // Clear the buffer
blit( buffer, ship, 0, 0, x, 400, ship->w, ship->h); // Blit the ship to the buffer
blit( buffer, screen, 0, 0, 0, 0, 640, 480); // Blit the buffer to the screen
}
destroy_bitmap(buffer);
destroy_bitmap(ship);
allegro_exit();
return 0;
}
END_OF_MAIN();
it works.... with some minor blinking that is...