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

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

From: Jay Reeve <jktr@...>
Date: Thu, 9 Sep 99 02:43:40 -0500
>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).
>
Hi Jon,

Here's some code I slapped together. Sorry it isn't elegant and isn't 
documented, but see if it does what you're looking for. There are some 
other things you should do with it, but this will give you some idea of 
the possibilities.

 0"0
 =J= a  y
  "


DIM gPictRect.8;0,gPrT,gPrL,gPrB,gPrR
DIM gclipRect.8;0,gCrT,gCrL,gCrB,gCrR

DIM gProgramEnds
DIM gPanelUp,gMoveTime&
DIM gMyPict&
DIM gIsOpen
END GLOBALS

LOCAL FN doEvents
  evnt = {EVENT}
  
  SELECT evnt
    CASE _nullEvt
      LONG IF gPanelUp
        LONG IF FN TICKCOUNT > gMoveTime&+2
          temp& = FN NEWRGN
          CALL GETCLIP(temp&)
          gCrT = 98+gPanelUp
          gCrB = 102 + gPanelUp
          myRgn& = FN NEWRGN
          CALL RECTRGN(myRgn&,gclipRect)
          CALL SETCLIP(myRgn&)
          CALL DRAWPICTURE(gMyPict&,gPictRect)
          CALL SETCLIP(temp&)
          CALL DISPOSERGN(myRgn&)
          CALL DISPOSERGN(temp&)
          DEC(gPanelUp)
          DEC(gPanelUp)
          gMoveTime& = FN TICKCOUNT
        END IF
      END IF
  END SELECT
END FN

LOCAL FN init
  CALL SETRECT(gPictRect,0,0,50,50)
  CALL SETRECT(gPictRect,200,100,250,150)
  gclipRect = gPictRect
  COLOR _zred
  pat = 128
  CALL PAINTRECT(gPictRect)
END FN

LOCAL FN makePicts
  CALL SETRECT(gPictRect,0,0,50,50)
  gMyPict& = FN OPENPICTURE(gPictRect)
  COLOR _zblue
  CALL PAINTRECT(gPictRect)
  PEN 7,2
  COLOR _zyellow
  CALL FRAMEOVAL(gPictRect)
  CALL CLOSEPICTURE
  
  CALL SETRECT(gPictRect,200,100,250,150)
  gclipRect = gPictRect
  COLOR _zred
  pat = 128
  CALL PAINTRECT(gPictRect)
END FN

LOCAL FN doMouse
  evnt = USR ABS(MOUSE(0))
  SELECT evnt
    CASE _click1
      LONG IF gIsOpen
        FN init
      XELSE
        gPanelUp = 48
        gMoveTime& = EVENT&
      END IF
      DEF TOGGLE(gIsOpen)
  END SELECT
END FN

LOCAL FN makeWindow
  WINDOW #1,"MouseDraw",,_doc
  PRINT: PRINT "Click to activate/reset.
  PRINT :PRINT "Press cmd-period to exit."
END FN

'----------------------- Main -------------------------------
FN makeWindow

FN makePicts

ON MOUSE FN doMouse
ON EVENT FN doEvents

DO
  HANDLEEVENTS
UNTIL gProgramEnds