• Rise from your gwave!

Another C question...

Discussion in 'Saturn Dev' started by Daniel Eriksson, Jan 15, 2002.

  1. Daniel Eriksson

    Daniel Eriksson New Member

    Is there a command in Saturn C that is similiar to SLEEP in basic. That stops the program until a button is pressed or the time goes out? Please help. I am making a game and i would need this!
  2. RadSil

    RadSil New Member

    Just do a while loop and check for a button press, and then break the loop when the button is pressed...
  3. Daniel Eriksson

    Daniel Eriksson New Member

    Thanks, but how is the code to do that? I am very new to this. I am making a text adventure game and i would need a function like that.
  4. ExCyber

    ExCyber Staff Member

    That won't do what he was asking for... I think what's needed is something like this (again, this isn't guaranteed to be correct):

    void sleepuntilbutton (Uint32 frames)
      while (frames > 0)
       if (Smpc_Peripheral[0].data && PER_DGT_TX) return;
    This would (in theory) sleep for the specified number of frames, or until the X button is pressed. Of course, for a "real" program you'd probably want to abstract the button handling somehow...

    edit: D'oh! Forgot the closing code tag...

    (Edited by ExCyber at 4:21 pm on Jan. 15, 2002)
  5. Daniel Eriksson

    Daniel Eriksson New Member

    Thanks again! I´ll try it.
  6. RadSil

    RadSil New Member

    Oops. Didn't notice the "until time goes out"... I could have been more specific anyway :)

Share This Page