Board index » delphi » Draw without flicker.

Draw without flicker.

Hello,

I am writing this a program where this ball rolls across the screen. I do it
by clearing the screen with cleardevice; and then drawing everything that
was on the screen once again, but with the ball a step further. This causes
a horrible flicker. Is there anyway of drawing a picture (the background)
and maintaining it on the screen?

Thanks,

-John

P.s: Using TPascal 5.5.

 

Re:Draw without flicker.


Quote
"John Rel" wrote:
> I am writing this a program where this ball rolls across the screen. I do it
> by clearing the screen with cleardevice; and then drawing everything that
> was on the screen once again, but with the ball a step further. This causes
> a horrible flicker. Is there anyway of drawing a picture (the background)
> and maintaining it on the screen?
> P.s: Using TPascal 5.5.

I don't know if this will work with version 5.5, but here you go:

Draw the background. Before you draw the sprite (that is, the moving
ball) at its initial location, save the part of the background that
will be covered by the ball using GetImage. Now draw the ball.
To move the ball, overwrite it with the part of the background you
saved previously (using PutImage) and proceed similarly for the next
steps.

In fact it shouldn't be too hard to figure out if you know how
pointers work and by looking up the following routines in the
online help:

ImageSize
GetImage
PutImage

Re:Draw without flicker.


Thanks a lot. My 3rd lesson with pascal, but I got this one. No problems
till my circle had to climb a hill. This {*word*193} corner (from getimage) sticks
into the slope of the hill.
Still trying to figure it out .....

-John

Re:Draw without flicker.


John Rel heeft geschreven in bericht
<8ie6r7$fh...@rzsun03.rrz.uni-hamburg.de>...
Quote
>Thanks a lot. My 3rd lesson with pascal, but I got this one. No
problems
>till my circle had to climb a hill. This {*word*193} corner (from getimage)
sticks
>into the slope of the hill.
>Still trying to figure it out .....

>-John

I think the answer is something like IIRC:
Save the background (hill without circle) with another GetImage.
Put the circle on the hill with PutImage(...., ANDput).
That is: both circle and slope of the hill.
Then restore slope without circle from the saved image.

Experiment with ORput and XORput to find better ways to do what you
want it to do.

Hope this helps. Huub.

Re:Draw without flicker.


Re:Draw without flicker.


Dear Jhon i've found on internet a very good tutorial on graphics routines
that solve your problem but it makes use of  TURBO Pascal version 6.0.I
don't remember where i found it but it is from Denthor of Asphyxia.If you
cannot find it by yourself email me and i will send you that tutorial.
                                                    Gianpaolo
email: gianp...@libero.it

Quote
John Rel <re...@cheerful.com> wrote in message

8iduhg$dj...@rzsun03.rrz.uni-hamburg.de...
Quote
> Hello,

> I am writing this a program where this ball rolls across the screen. I do
it
> by clearing the screen with cleardevice; and then drawing everything that
> was on the screen once again, but with the ball a step further. This
causes
> a horrible flicker. Is there anyway of drawing a picture (the background)
> and maintaining it on the screen?

> Thanks,

> -John

> P.s: Using TPascal 5.5.

Re:Draw without flicker.


Why not floodfill the ball with the background colour, and then
redraw the ball in the new position. This should stop the
flicker of the screen been redrawn.

Just a suggestion

James

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com

Re:Draw without flicker.


I solved this problem by using getimage - but one pixel bigger than the
circle. I simply use a loop and move it with putimage pixel by pixel. The
extra one pixel erases the former picture.

-John

Other Threads