Mail Archives: djgpp/1998/04/17/16:47:25
>I've just barely gotten into animation
>with Allegro. I'm trying to animate a man
>walking by over a rather intricate background
>image.
>
> If I don't erase the man after each frame,
>he'll look like a solid streak across the
>screen. (he's only advancing one pixel at a
>time) I can't just print a black spot where
>the old frame used to be, because I'd lose
>my background image.
>
> I tried using create_sub_bitmap() to copy
>the section of the background image that would
>be changed, so I could print the "MAN" on the
>screen, and clear him by using blit() like so:
>
>tempbmp=create_sub_bitmap(screen, x, y, 100, 100);
>draw_sprite(screen, man, x, y);
>vsync();
>blit(temp, screen, 0, 0, x, y, 100, 100);
>
> And then, I repeat the process, changing x and y
>to move the image....
>
> So, what'm I doing wrong? Any assistance
>would be greatly appreciated.
>
>Thank you.
>Anthony A. Tedjamulia
Try the following:
drawbitmap=createbitmap(SCREEN_W,SCREEN_H);
backbitmap=createbitmap(SCREEN_W,SCREEN_H);
// copy background-data to "backbitmap"
while(1)
{
blit(backbitmap,drawbitmap,0,0,0,0,SCREEN_W,SCREEN_H);
// change x,y by whatever value you want,
// and change number and size and
// transparency of your sprites as you want
// let them overlap, just everything...
draw_sprite(drawbitmap, man, x, y);
vsync();
blit(drawbitmap, screen, 0, 0, x, y, 100, 100);
}
This works perfectly well (and fast) with me, you dont need
sub_bitmaps, or redrawing any background, and it
provides double-buffering...
hope this helps,
Elias Pschernig
- Raw text -