More Maze Handlers

Date:    Thu, 1 Feb 1996 09:52:18 -0600
From:    Lon Koenig <lon@RLADVERT.COM>
Subject: Re: Maze help!
A slightly fancier version of John Dowdell's maze handler script. The visible sprites are placed using Matte Ink.
on mouseDown
  -- Constants:
  set hiddenSprite=48   -- Channel used to pre-test object's location
  set mapSprite=1       -- Map of allowable area
  set testX=the mouseH  -- save the mouse position RIGHT NOW!
  set testY=the mouseV
  set me to the clickOn -- Remember which channel this object is using

  -- Calculate the mouse's offset from the object's registration point
  set offsetestX to the locH of sprite me
  set offsetestY to the locV of sprite me
  set offsetestX=offsetestX-testX
  set offsetestY=offsetestY-testY

  set the castNum of sprite hiddenSprite to the castNum of sprite me
  set the visible of sprite hiddenSprite to FALSE
  set goodX=the mouseH+offsetestX
  set goodY=the mouseV+offsetestY


  --Track the movement:
  repeat while the stillDown

    -- Test for the collision:
    set testX=the mouseH+offsetestX
    set testY=the mouseV+offsetestY
    set the loc of sprite hiddenSprite to point(testX, testY)
    updateStage
    if (sprite hiddenSprite within mapSprite) then
      set the loc of sprite me to point(testX, testY)
      set goodX=testX
      set goodY=testY

    else
      set the loc of sprite me to point(goodX, goodY)

      updateStage
    end if
  end repeat

end mouseDown