Welcome to Phrogram Sign in | Join | Help
in Search


To write a pause and unpause

Last post 08-01-2008, 12:02 PM by TomDad. 14 replies.
Sort Posts: Previous Next
  •  07-27-2008, 8:54 AM 6952

    To write a pause and unpause

    What is the code to pause something and then unpause it.

    :)
    The best progamer
  •  07-27-2008, 10:11 AM 6953 in reply to 6952

    Re: To write a pause and unpause

    Try Delay(milliseconds as integer) in the Shell library.
  •  07-27-2008, 10:13 AM 6954 in reply to 6953

    Re: To write a pause and unpause

    So write delay and with the key that i want it to pause it right

     


    :)
    The best progamer
  •  07-27-2008, 10:19 AM 6955 in reply to 6954

    Re: To write a pause and unpause

    it doesn't seem to be working I put
     If IskeyDown("p") Then

    Delay(500)

    End if

    Can you please tell me what is wrong

     


    :)
    The best progamer
  •  07-27-2008, 2:47 PM 6959 in reply to 6955

    Re: To write a pause and unpause

    Attachment: Pausable.kpl

    DavidW:

    Try Delay(milliseconds as integer) in the Shell library.

     

    Delay() will not give you a pause/unpause feature. Delay() only makes the program stop for so many milliseconds and then take off a gain. It will not work for a pause feature.

    @ Phoex 

    If you want a pause/unpause key, I made an example program that shows one way to do it.


  •  07-27-2008, 7:53 PM 6962 in reply to 6959

    Re: To write a pause and unpause

    Ok Thanks. If you please could i see the example code.

    :)
    The best progamer
  •  07-28-2008, 4:51 AM 6964 in reply to 6962

    Re: To write a pause and unpause

    Try This:

    If IsKeyDown("p") Then // When p is pressed
     While IsKeyDown("p") // Wait until p is released
     Delay(1)
     End While
     While Not IsKeyDown("p") // Wait until p is pressed again
     Delay(1)
     End While
    End If

    Michael

  •  07-28-2008, 4:52 PM 6973 in reply to 6964

    Re: To write a pause and unpause

    hey now when i pause it won't unpause

     


    :)
    The best progamer
  •  07-29-2008, 6:23 AM 6975 in reply to 6964

    Re: To write a pause and unpause

    Sorry, didn't test it in a fast loop. Add another While loop.

    If IsKeyDown("p") Then // When p is pressed
     While IsKeyDown("p") // Wait until p is released
     Delay(1)
     End While
     While Not IsKeyDown("p") // Wait until p is pressed again
     Delay(1)
     End While

    While IsKeyDown("p") // Wait until p is released
     Delay(1)
     End While

    End If

    Hope it works now for you

    Michael

  •  07-29-2008, 2:18 PM 6977 in reply to 6975

    Re: To write a pause and unpause

    Another idea for pausing a game (this is usually the one i use)...

    if iskeydown("p") then

    alert("paused","paused")

    end if

    ...making an alert box is much easier then most other  methods of pausing since it only uses one line of code. Using this way however severely limits other possibilities and options such as making a pause menu etc...


    I wonder... do phrogs eat phlies????
  •  07-29-2008, 3:15 PM 6978 in reply to 6962

    Re: To write a pause and unpause

    Attachment: Pausable.kpl

    phoex:
    Ok Thanks. If you please could i see the example code.

    Oh! *smacks self on forehead* Why on Earth didn't I attach it before?? That was rather silly of me. How could I forget that? It should be there now.

  •  07-29-2008, 8:25 PM 6981 in reply to 6978

    Re: To write a pause and unpause

    Hey thanks now it is working i combined your ideas into one huge one but how dra progger was explain that i could make a pause menu. is it possible to make like other buttons in the alert like "new game"

    :)
    The best progamer
  •  07-30-2008, 3:12 PM 6982 in reply to 6981

    Re: To write a pause and unpause

    No, it isn't possible to make your own buttons on the alert box. I don't really see why not, because it should be relatively simple ( new feature request - hint hint ), but you just can't.
  •  07-30-2008, 9:24 PM 6985 in reply to 6981

    Re: To write a pause and unpause

    Unfortunately, Dragon Rider is right. There is another box though that might come in handy...

    if confirm("Do you want to quit?","Do you want to quit?") = true then //if user presses the 'yes' button

    stop()

    else //if user pushes any other button(the 'no' button)

     

    end if


    I wonder... do phrogs eat phlies????
  •  08-01-2008, 12:02 PM 6994 in reply to 6981

    Re: To write a pause and unpause

    Maybe you need to create your own "alert box" and user buttons. Don't know what level at your at; but have a think...!
    TomDad. Tom is my son...and I'm his Dad. So we are TomDad Software.
View as RSS news feed in XML