On Thu, 22 Jul 1999, Karl Becker wrote:

> This is my first posting to the list here, and I think it's of interest 
> to many people.
> 
> The problem I'm experiencing is with the Mouse() function.  When I put 
> the following line into a repeating loop:
> 
>    wait until the mouse is down
> 
> or
> 
>    if the mouse is down then  ...
> 
> it only works some times.  On the first time through the loop, it will 
> correctly tell me the current state of the mouse button  (I'm on a Mac, 
> and using a one-button mouse, but a multiple button mouse should work 
> with this, too) .  However, when it loops around and comes to one of 
> those two lines, it cannot tell if the mouse is pressed.  The only 
> message it gets (for some unknown reason) is that the mouse is up, even 
> when I'm pressing and holding it down.  (I've checked this by making a 
> repeat loop which puts the result of Mouse() into msg box)
> 
> Here's part of a script I'm talking about:
> 
> 
> repeat until givenTheSign is "stay"
>    wait until the mouse is down  --**Also could be "wait until Mouse() is 
> down"
>    put the mouseLoc into someVariable
>    doOtherStuff
> end repeat
> 
> 
> The first time through the repeat, it keeps checking to see if the mouse 
> is down and, when it's depressed, it moves on to the next line (put the 
> mouseLoc into someVariable) .  
> However, the next time through the loop, it just gets stuck on "wait 
> until the mouse is down".  This is quite important for a few games I'm 
> working on, including a basketball and casino game.  What could I do 
> about this peculiarity?

I'm not sure what the problem is here (and suspect that it has a lot
to do with what happens in "doOtherStuff"), but as a general rule in
MetaCard, *never* use "wait until X" or "repeat until Y" where Y is
any user-initiated change.  It's a horribly inefficient way to things
(the technical term is polling, which is the antithesis of the
event-driven model all GUIs and multi-tasking OSs are built on).

You'll get much smoother response and consume a fraction of the CPU
time if you use the mouseDown/mouseUp/mouseRelease/mouseMove messages,
possibly in combination with "send .. in" for things that need to be
done periodically (e.g., making flashing buttons, or changing the
frame in a GIF at a non-standard rate).  It's harder to develop this
way because the important routines end up getting scattered over
several handlers, but is the only way to go, especially for
time-critical applications like games.
  Regards,
    Scott

> Thanks for your time!
> 
> --------------------------------
> Karl Becker, [EMAIL PROTECTED]
> http://www.btigate.com/~funkboy/
> Featuring: Tiger's Eye Casino, 
> MacBasketball, and The Fishin' Hole!
> 

********************************************************
Scott Raney  [EMAIL PROTECTED]  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...

Reply via email to