Author Topic: Pause game  (Read 10510 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Pause game
« on: January 07, 2011, 09:44:22 am »
Hey, I know that some of you have made games with pausing systems that work with a key to pause the game.

How does that work? How do you do it?

I wanted to implement it in uPong and was wondering how.

Thanks much!

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Pause game
« Reply #1 on: January 07, 2011, 09:48:51 am »
If getkey(Y)
Repeat getkey(X)
End:End

?

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Pause game
« Reply #2 on: January 07, 2011, 09:52:40 am »
If getkey(Y)
Repeat getkey(X)
End:End

?

Code: [Select]
If getKey(9)
Repeat getKey(9)
End:End

For the ENTER Key... I have to try it yet, thanks.


EDIT: It doesn't work, probably it is only getting the getKey, no actualing stopping the game.
« Last Edit: January 07, 2011, 09:54:35 am by ScoutDavid »

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Pause game
« Reply #3 on: January 07, 2011, 09:55:26 am »
don't do it with the same key ( it will directly exit from the loop )

try it

Code: [Select]
If getkey(9)
While getkey-9
End:End

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Pause game
« Reply #4 on: January 07, 2011, 10:03:04 am »
don't do it with the same key ( it will directly exit from the loop )

try it

Code: [Select]
If getkey(9)
While getkey-9
End:End

That works more or less :S It pauses the game, but when I put it back on, it only lasts 1 second and then is paused again :S

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Pause game
« Reply #5 on: January 07, 2011, 10:04:47 am »
hmmm ok try this :P

Code: [Select]
!If getkey-9
Repeat getkey-9
End:End

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Pause game
« Reply #6 on: January 07, 2011, 10:19:07 am »
This is what I do -

Code: [Select]
While getkey(0)
    Dispgraph[r]
End

Repeat getKey(0)
    Dispgraph[r]
End

« Last Edit: January 07, 2011, 10:19:15 am by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline c.sprinkle

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 221
  • Rating: +23/-1
  • There ain't no rest for the wicked? True indeed.
    • View Profile
    • The Corread on NationStates.
Re: Pause game
« Reply #7 on: January 07, 2011, 10:22:37 am »
I use:
Code: [Select]
If getKey(45
Repeat getKey
DispGraph[r]
End
End
« Last Edit: January 07, 2011, 10:22:55 am by c.sprinkle »

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Pause game
« Reply #8 on: January 07, 2011, 10:25:13 am »
I use APD command for the "pause"

Ashbad

  • Guest
Re: Pause game
« Reply #9 on: January 07, 2011, 01:20:02 pm »
me:

Code: [Select]
Repeat getkey(0)
Dispgraph[r]
End
Repeat getKey(0)-1
Dispgraph[r]
End


Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Pause game
« Reply #10 on: January 07, 2011, 01:54:42 pm »
Me:

Quote
Repeat getkey-9
Dispgraphrr
End

You don't really need anything more complicated.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Pause game
« Reply #11 on: January 07, 2011, 01:59:19 pm »
I use APD command for the "pause"

What's that?

This is what I do -

Code: [Select]
While getkey(0)
    Dispgraph[r]
End

Repeat getKey(0)
    Dispgraph[r]
End



This is pretty much what I use. It's really nice because it doesn't go forward when the button's still held down. Plus you can use the second loop to do some nice effects.




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Pause game
« Reply #12 on: January 07, 2011, 02:01:43 pm »
@Deep_Thought: Me too.

@Michael_Lee: Yours works perfectly! Thank you very much. +1

Ashbad

  • Guest
Re: Pause game
« Reply #13 on: January 07, 2011, 02:03:57 pm »
@Michael_Lee: Yours works perfectly! Thank you very much. +1

Can I have a +1 too for being awesome?

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Pause game
« Reply #14 on: January 07, 2011, 02:10:16 pm »
you can also make a teacher key by doing this if you don't have greyscale for the second method in parentheses.
Code: [Select]
If getkey(X)
Repeat getkey(X) and getkey(Y)
(Here you can set the contrast to 0 or do this)
Copy(L6,L3,768)
ClrDraw
End
Copy(L3,L6,768)

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>