www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/04/17/16:47:25

From: "Elias Pschernig" <f DOT x DOT gruber-museum-arnsdorf AT magnet DOT at>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Help: Allegro and animating...
Date: Fri, 17 Apr 1998 09:44:16 +0200
Organization: magnet Internet Services
Lines: 75
Message-ID: <6h8bf0$ik$1@orudios.magnet.at>
References: <353788DC DOT F297ED77 AT sprynet DOT com>
NNTP-Posting-Host: 195.3.67.133
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

>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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019