[futurebasic] Re: [FB] Panel Animation in FB

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1999 : Group Archive : Group : All Groups

From: Mel Patrick <mel@...>
Date: Wed, 8 Sep 1999 15:26:53 -0700
>Hi to all from a newbie on this list.
>
>I'm trying to write an experiment in which I want people to pick a box with
>the mouse, then I want the box to appear to have a panel that slides up to
>reveal a prize (in the form of a pict resource) behind it (or not=black,
>means they picked the wrong one).
>
>I have the placing of picts and the picking with the mouse and that stuff
>done fine.  My problem is with the panel effect.  I have tried drawing the
>pict, then a succesively smaller box, then a delay, then the pict again but
>it looks too choppy.  Its close, but not believable since when the pict
>draws it flashes up for a bit on the panel area.  What I really need is a
>way to have the pict draw in a line at a time perhaps.  I don't have time
>for learning machine code, I'm too old, thats why I like FB.
>
>My code attempt as it is...
>
>  MyPict&=FN GETPICTURE (128)
>  DIM rect.8
>  CALL SETRECT(rect,0,0,145,145)
>
>  COLOR=_zBlack
>  FOR I=145 TO 0 STEP -5
>    CALL DRAWPICTURE (MyPict&,rect)
>    BOX FILL 0,0 TO 145,I
>    DELAY 100
>  NEXT I
>
>Anyone have any ideas, sample code snips, places I should look?

My guess would be something like this :

LOCAL FN DrawPictPop(PictID)
DIM rect;0,t,l,b,r:'                               default rect to use
   t=143:l=0:r=145:b=145
   Hndl&=FN GETRESOURCE(_"PICT",PictID):'            get handle to pict
    LONG IF Hndl&:'                   did we get a handle for this PICT
     saveRgn&=FN NEWRGN:'                            build a new region
      LONG IF saveRgn&:'                  we need to check to make sure
       CALL GETCLIP(saveRgn&):'                save the original region
         FOR t=143 TO 0 STEP -2:'        draw the PICT higher each time
          CALL CLIPRECT(rect):'                 only update this region
          PICTURE(l,t),Hndl&:'            draw at specified coordinates
         NEXT t
       CALL SETCLIP(saveRgn&):'            restore the old region first
       CALL DISPOSERGN(saveRgn&):'   then get rid of the memory it used
      END IF
    CALL RELEASERESOURCE(Hndl&):'          free the memory PICT used
    END IF
END FN

Totally untested I might add but the logic is kinda there. The 
CLIPRGN is the area that the pict is allowed to draw into. Anything 
outside of that defined rect is not touched. This is usually simpler 
than fiddling with off screen gworlds.

If you wanted to specify the RECT if you have different areas, then 
you'd need to pass the rect coordinates to the function so then this 
routine would work anywhere in your window.

Hope it helps.

Mel Patrick
mel@...