1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
BITMAP *my_pic = NULL; //Declare a BITMAP called my_pic
my_pic = load_bitmap("picture.bmp", NULL); // Load our picture
/* Declare another bitmap. This will be our 'buffer'. */
BITMAP *buffer = NULL; //Declare a BITMAP called buffer.
buffer = create_bitmap(640,480); //Create an empty bitmap.
int my_pic_x = 0;// Holds our pictures X coorinate
int my_pic_y = 0;// Holds our picture's Y coordinate
while(!key[KEY_ESC]) //If the user hits escape, quit the program
{
if(key[KEY_RIGHT])
{
my_pic_x ++;
}
else if(key[KEY_LEFT]) {
my_pic_x --;
}
else if(key[KEY_UP])
{
my_pic_y --;
}
else if(key[KEY_DOWN])
{
my_pic_y ++;
}
draw_sprite(buffer, my_pic, my_pic_x, my_pic_y);
blit(buffer, screen, 0,0,0,0,640,480); // Draw the buffer to the screen
clear_bitmap(buffer);
} |
Partager