Hello,
I am making a game in byob, and altough there is an pause button above the "game screen" I would like to program one that pauses/resumes the game when i press "p".
can anyone tell or even show me how to do that?
many thanx,
Arne
Offline
When (P key) pressed if <(Play/Pause) = [1] Set (Play/Pause) to [0] end if <(Play/Pause) = [0]> Set (Play/Pause) to [1]Then have all of your stuff set up so:
Offline
Oops. I messed up.
When (P key) pressed if <(Play/Pause) = [1]> Set (Play/Pause) to [0] end if <(Play/Pause) = [0]> Set (Play/Pause) to [1]Then have all of your stuff set up so:
if <(Play/Pause) = [0]> Make all of the keys that control your sprite don't do anything end if <(Play/Pause) = [1]> Have all of your keys do what they want. end
Offline
Maltese_Falcon wrote:
Oops. I messed up.
When key [p v] pressed forever if <(Play/Pause) = [1]> Set [Play/Pause v] to [0] end if <(Play/Pause) = [0]> Set [Play/Pause v] to [1] end endThen have all of your stuff set up so:forever if <(Play/Pause) = [0]> Make all of the keys that control your sprite don't do anything end if <(Play/Pause) = [1]> Have all of your keys do what they want. end end
Fixed
With regards
~7734f
Last edited by 7734f (2013-03-27 19:57:44)
Offline
thanks a lot everybody!!!
Offline
Small improvement, because as far as I know the when key pressed hats work like the when I recieve hat blocks in that they restart whenever the key is pressed (even if it is waiting) so if you put
forever if <key [p v] pressed? > set [pause v] to (( 1 ) - (pause)) end wait until <not <key [p v]pressed?>>under whatever hat block starts the bit of your game that you want to pause that should hopefully work better.
if <(pause) = [0]> first block of your code else if <(pause) = [0]> second block of your code else if <(pause) = [0]> third block of your code else if <(pause) = [0]> fourth block of your code else if <(pause) = [0]> fifthe block of your code else end end end end end
Offline
Sorry I meant:
if <(pause) = [0]> first block of code if <(pause) = [0]> second block of code if <(pause) = [0]> third block of code e.t.c. end end end.
Offline
Another way you could do it is:
when gf clicked set [pause] to [false]
when [p] key pressed set [pause] to [true] wait until <key [p] pressed> set [pause] to [false]hope this works
Last edited by topazdragonlord (2013-03-28 15:36:38)
Offline