Would anyone know how to create a pause feature for a basic game using :getkey and :pause? I would like to add it to a game called Nibbles.
Depends on what variable you are using for key detection, though it'd simply be something like this:

We're assuming getKey->K

If K=105:Pause

105 is your Enter key, by the way.

Posting your code up for us to see would make it easier for us to help you see what's not working correctly.
This is it (btw not mine, found online and I started to find my way around BASIC)


Code:
:AxesOff:FnOff
:ClrDraw
:ZStandard
:104→Xmax
:‾72→Ymin
:ZInteger
:Line(94,0,94,‾61
:Line(0,0,0,‾61
:Horizontal 0
:Horizontal ‾61
:41→A:Ans→E
:29→B:Ans→F
:1→H:0→V
:5→S:0→θ
:Pt-On(41,‾29,2
:Repeat not(pxl-Test(N-1,M-1
:2+3int(31rand→M
:2+3int(20rand→N
:End
:Pt-On(M,‾N,2
:Pt-Off(M,‾N,3
:Pxl-On(N,M
:Repeat 0
:getKey→K
:If Ans:Then
:If H:Then
:(Ans=34)-(Ans=25→V
:If Ans
:0→H
:Else
:(Ans=26)-(Ans=24→H
:If Ans
:0→V
:End
:End
:If H:Then
:A+3H→A
:If pxl-Test(B,Ans-H)
:Then
:Text(27,34,"SCORE:",θ
:Return
:End
:Pt-On(Ans,‾B,2
:Pxl-Off(B,Ans-H
:Pxl-Off(B,Ans-2H
:Else
:B+3V→B
:If pxl-Test(Ans-V,A:Then
:Text(27,34,"SCORE:",θ
:Return
:End
:Pt-On(A,‾Ans,2
:Pxl-Off(Ans-V,A
:Pxl-Off(Ans-2V,A
:End
:If pxl-Test(B,A
:Then
:Pxl-Off(B,A
:Repeat not(pxl-Test(N-1,M-1
:2+3int(31rand→M
:2+3int(20rand→N
:End
:Pt-On(M,‾N,2
:Pt-Off(M,‾N,3
:Pxl-On(N,M
:If θ=95:Then
:Text(27,34,"WIN.
:Return
:End
:Pxl-On(62,θ
:1+θ→θ
:S+3→S
:End
:If S:Then
:S-1→S:Else
:pxl-Test(F,E-1)-pxl-Test(F,E+1
:If Ans:Then
:Pxl-On(F,E+2Ans
:Pt-Off(E,‾F,2
:E+3Ans→E
:Else
:1-2pxl-Test(F+1,E
:Pxl-On(F+2Ans,E
:Pt-Off(E,‾F,2
:F+3Ans→F
:End
:End
:End
but thats it if anyone can help get a pause feature in.
Try this (I don't do TI BASIC dev anymore, no idea if this works):


Code:
:AxesOff:FnOff
:ClrDraw
:ZStandard
:104→Xmax
:‾72→Ymin
:ZInteger
:Line(94,0,94,‾61
:Line(0,0,0,‾61
:Horizontal 0
:Horizontal ‾61
:41→A:Ans→E
:29→B:Ans→F
:1→H:0→V
:5→S:0→θ
:Pt-On(41,‾29,2
:Repeat not(pxl-Test(N-1,M-1
:2+3int(31rand→M
:2+3int(20rand→N
:End
:Pt-On(M,‾N,2
:Pt-Off(M,‾N,3
:Pxl-On(N,M
:Repeat 0
:getKey→K
:If Ans:Then
:If H:Then
:(Ans=34)-(Ans=25→V
:If Ans
:0→H
:Else
:(Ans=26)-(Ans=24→H
:If Ans
:0→V
:End
:End
:If k=22:Then
:StorePic 0
:ClrDraw
:Pause "Paused"
:RclPic 0
:End
:If H:Then
:A+3H→A
:If pxl-Test(B,Ans-H)
:Then
:Text(27,34,"SCORE:",θ
:Return
:End
:Pt-On(Ans,‾B,2
:Pxl-Off(B,Ans-H
:Pxl-Off(B,Ans-2H
:Else
:B+3V→B
:If pxl-Test(Ans-V,A:Then
:Text(27,34,"SCORE:",θ
:Return
:End
:Pt-On(A,‾Ans,2
:Pxl-Off(Ans-V,A
:Pxl-Off(Ans-2V,A
:End
:If pxl-Test(B,A
:Then
:Pxl-Off(B,A
:Repeat not(pxl-Test(N-1,M-1
:2+3int(31rand→M
:2+3int(20rand→N
:End
:Pt-On(M,‾N,2
:Pt-Off(M,‾N,3
:Pxl-On(N,M
:If θ=95:Then
:Text(27,34,"WIN.
:Return
:End
:Pxl-On(62,θ
:1+θ→θ
:S+3→S
:End
:If S:Then
:S-1→S:Else
:pxl-Test(F,E-1)-pxl-Test(F,E+1
:If Ans:Then
:Pxl-On(F,E+2Ans
:Pt-Off(E,‾F,2
:E+3Ans→E
:Else
:1-2pxl-Test(F+1,E
:Pxl-On(F+2Ans,E
:Pt-Off(E,‾F,2
:F+3Ans→F
:End
:End
:End
The section that dealt with pausing wasn't exactly right, it'd be more like:


Code:
:If K=22:Then
:StorePic 0
:ClrDraw
:Text(28,40,"PAUSED"
:Pause
:RclPic 0   -'must be Pic0 if this is the TI-83 not +
:End


Or to be faster and not use Pics:


Code:
:If K=22:Then
:ClrHome
:Disp "PAUSED"
:Pause
:End
CalebHansberry wrote:
The section that dealt with pausing wasn't exactly right, it'd be more like:


Code:
:If K=22:Then
:StorePic 0
:ClrDraw
:Text(28,40,"PAUSED"
:Pause
:RclPic 0   -'must be Pic0 if this is the TI-83 not +
:End


Or to be faster and not use Pics:


Code:
:If K=22:Then
:ClrHome
:Disp "PAUSED"
:Pause
:End


Ah, confused the graph and home screen commands.
CalebHansberry wrote:


Code:
:If K=22:Then
:ClrHome
:Disp "PAUSED"
:Pause
:End


You can drop the Disp, and do Pause "PAUSED
tifreak8x wrote:
You can drop the Disp, and do Pause "PAUSED


Ah, I didn't know. So you can (though it is for the homescreen only).
tifreak8x wrote:
You can drop the Disp, and do Pause "PAUSED

In this case, yes, but you must never use a Pause argument to disturb Ans when it is "hot" as a temporary variable.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement