--- Mickey Mathieson <[EMAIL PROTECTED]> wrote:
>
> --- GLOGIC 20 <[EMAIL PROTECTED]> wrote:
>
> >
> > hi its in 2d..
> > this is what i have at the moment and it will do
> the
> > job i suppose.
> > Basically when a collsion occurs startexplosion is
> > called to initialize the
> > values needed, such as the position of the ship
> and
> > random directions to
> > move in, live span of each particle. each time
> > updateexplosion is called
> > from a timer it moves each bit in the velocity it
> > has and decrements the
> > live of the particle.
> > any ideas of how to improve it? or a better way to
> > tackle it even?
> > oh and any idea how to stretch an image to set as
> > background of the form?
> > thanks
> > gav
> >
> >
> > void UpdateExplosion(){
> >
> >
> > //move the explosion pieces for the next
> > frame
> > for (int i = 0;i<MAX_EXPLOSION_BITS;i++)
> > {
> >
> >
> > explode[i].position =
> > Add(explode[i].position ,
> > explode[i].velocity );
> > explode[i].timetoLive--;
> >
> > if (explode[i].timetoLive ==
> > 0)
> > {
> > explode[i].alive = false;
> > }
> > }
> >
> >
> > }
> > void DrawExplosion(){
> > // draw each of the explosion bits
> > vector pos;
> > Form1->Canvas->Pen->Color = clGreen;
> > for (int i = 0;i<MAX_EXPLOSION_BITS;i++)
> > {
> >
> > if (explode[i].alive ==
> > true)
> > {
> >
> >
> >
> > Form1->Canvas->MoveTo(explode[i].position.x,
> > explode[i].position.y);
> >
> > pos =
> > Add(explode[i].position ,
> > explode[i].velocity );
> >
> > Form1->Canvas->LineTo(pos.x, pos.y);
> > }
> >
> > }
> >
> >
> >
> > }
> >
> === message truncated ===
>
>
>
> Its looks like your using c++ builder. If so there
> is
> a component called TPaintBox that might be better
> suited for simulating an explosion than using the
> canvas property to draw direct to the form.
>
> Check it out
>
>
There is one other potential problem using the canvas
property to draw directly to the form. You will have
to manually handle the Onpaint WM_Paint message. Also
will have to record all the information for each
explosion then when onpaint in fired redraw all the
explosion. But if you use the TPaintBox its handled
automatically. TPaintBox has its own canvas property
and acts as "Graphics Container".
Mickey M.
Construction Partner Inc.
http://www.constructionpartner.com
____________________________________________________________________________________
It's here! Your new message!
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/