Board index » cppbuilder » DoubleBuffered slows down ma machine like hell :((( any betta way?

DoubleBuffered slows down ma machine like hell :((( any betta way?


2003-11-15 12:52:21 AM
cppbuilder18
Heya Fellas,
I am making a stratego game and I got TShapes as my board and anyways
whenever
I try to move ma soldiers they flicker all over the screen, so I try
DoubleBuffered = true
but that thing makes ma computer run so freakishly slow I can die - I mean
all I want is
a 5 pixels movement 5 times a sec, I am using:
//------
for (int i = 0; i<5; i++){
Sold->Left += 5;
Sleep(200);
}
//------
and it takes it like 3 seconds before it makes the movement - I mean it's so
much
slower and iut makes everything so ugly and slow I can die.
I also tried to make it so that when I click a TShape it would change it's
Pen color
and it does do it but very slow and when DoubleBuffered is off it flickers
and then do it.
I am using BCB4 - maybe it's compiling settings are so primitive everything
is meant
to be so slow? or maybe there's something else except DoubleBuffered I can
use? I
thought of trying DirectDraw but I don't understand it at all.
Plz Help,
- Dragons Master
 
 

Re:DoubleBuffered slows down ma machine like hell :((( any betta way?

hi there,
"Dragons Master" < XXXX@XXXXX.COM >wrote in message
Quote
I try to move ma soldiers they flicker all over the screen, so I try
DoubleBuffered = true
but that thing makes ma computer run so freakishly slow I can die - I mean
all I want is
a 5 pixels movement 5 times a sec, I am using:
file://------
for (int i = 0; i<5; i++){
Sold->Left += 5;
Sleep(200);
}
file://------
I know this off topic, but does this Code actually worked ?? i doubt it
Quote
and it takes it like 3 seconds before it makes the movement - I mean it's
so
much
slower and iut makes everything so ugly and slow I can die.

I also tried to make it so that when I click a TShape it would change it's
Pen color
and it does do it but very slow and when DoubleBuffered is off it flickers
and then do it.
Suggestions for removing Doublebuffering
1) Directly draw to the canvas, *without erasing any contents*
2) Draw to an Offscreen bitmap, and in end of it draw everything to Canvas
3) use a Control derived from TWinControl, (eg TPanel) place your control
(which you want to Animate, in this case TShape) in that parent control, and
set the Double buffer property of the parent control to true, instead of
whole forms double buffer property
4) set the controls property to Opaque, since Flickering occours *whenever
any control Erases and Repaints itself*.
5) www.bcbdev.com/faqs/faq34.htm
many times i prefer 1) and 2) to be most appropriate and fast enough for my
games
hope this helps :-)
-Dumboo
 

Re:DoubleBuffered slows down ma machine like hell :((( any betta way?

have you seen the Example program the comes with CBuilder ??
C:\Program Files\Borland\CBuilder5\Examples\Games\EarthPng
this might help you
-Dumboo
 

{smallsort}

Re:DoubleBuffered slows down ma machine like hell :((( any betta way?

hi there
Quote
Yes it does work - why wouldn't it - the picture simply moves 5 pixels to
the right.
ohh yeah I moved the TImage not the TShape - Sold is a TImage.
well i said that, cause you are using Sleep(..) in your program,
whenever we are using Sleep it haults the program there itself until the
specified time is elasped, since your for(..) code is in one function, this
wont allow it to get the Messages from the windows message queue and hence
your program would look stuck *No Animation* (I have tried it) with no
matter which control you are using, until that controls animation is running
in Another Thread
the most appropriate way according to me would be to use a Timer, but since
it is working for you, its all up to u :-) whether you want to implement or
not :-)
Quote

| 1) Directly draw to the canvas, *without erasing any contents*
| 2) Draw to an Offscreen bitmap, and in end of it draw everything to
Canvas

ohh I got no idea how to work with the canvas thing - let's say I want a
my
TImage
to have a different Image, wut I do is this:
Sold->Picture->LoadFromFile("2ndpicture.bmp");
How do I do that thingy with the canvas thing? also if possible how do I
move the
TImage with the canvas thing? if possible.
you cannot move the TImage with the Canvas, i have prepared a simple example
for you and anyone who wants to know the basics of flicker free animation
using CLX/VCL components, at codecentral, have a look at following URL
codecentral.borland.com/codecentral/ccweb.exe/listing
Quote
| 5) www.bcbdev.com/faqs/faq34.htm

Whoa great thing - to be honest I didn't really get most of it 'cause I
got
no idea on
wut all those windows messages are but I'll try to get a hang on it.
You can always ask here in the newsgroup, we all are there to help you,
everybody started with the same cryptic looking program :-)
Quote
| hope it helps

Well it cheers me up to know that's possible,
good to know that :-)
-Dumboo
 

Re:DoubleBuffered slows down ma machine like hell :((( any betta way?

| hi there,
Heya :)
| I know this off topic, but does this Code actually worked ?? i doubt it
Yes it does work - why wouldn't it - the picture simply moves 5 pixels to
the right.
ohh yeah I moved the TImage not the TShape - Sold is a TImage.
| 1) Directly draw to the canvas, *without erasing any contents*
| 2) Draw to an Offscreen bitmap, and in end of it draw everything to Canvas
ohh I got no idea how to work with the canvas thing - let's say I want a my
TImage
to have a different Image, wut I do is this:
Sold->Picture->LoadFromFile("2ndpicture.bmp");
How do I do that thingy with the canvas thing? also if possible how do I
move the
TImage with the canvas thing? if possible.
| 5) www.bcbdev.com/faqs/faq34.htm
Whoa great thing - to be honest I didn't really get most of it 'cause I got
no idea on
wut all those windows messages are but I'll try to get a hang on it.
| hope it helps
Well it cheers me up to know that's possible, now I only need to understand
how :).
- Dragons Master
 

Re:DoubleBuffered slows down ma machine like hell :((( any betta way?

"Dragons Master" < XXXX@XXXXX.COM >schreef in bericht
Quote
Heya Fellas,
I am making a stratego game and I got TShapes as my board and anyways
whenever
I try to move ma soldiers they flicker all over the screen, so I try
DoubleBuffered = true
but that thing makes ma computer run so freakishly slow I can die - I mean
all I want is
a 5 pixels movement 5 times a sec, I am using:
//------
for (int i = 0; i<5; i++){
Sold->Left += 5;
Sleep(200);
}
//------
with Sleep you interrupted your program for 200ms This is time you better
can use for other things in your program.
Quote

and it takes it like 3 seconds before it makes the movement - I mean it's
so
much
slower and iut makes everything so ugly and slow I can die.

I also tried to make it so that when I click a TShape it would change it's
Pen color
and it does do it but very slow and when DoubleBuffered is off it flickers
and then do it.

I am using BCB4 - maybe it's compiling settings are so primitive
everything
is meant
to be so slow? or maybe there's something else except DoubleBuffered I can
use? I
thought of trying DirectDraw but I don't understand it at all.

Plz Help,
- Dragons Master