Have you ever played Nibbles before?
Yes
 33%  [ 1 ]
No
 66%  [ 2 ]
Total Votes : 3

So far, I have modified the Nibbles game (works correctly, no errors) so it exits outside the program, instead of inside the program.

Original code:

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


Modified Code:

Code:

ClrDraw
ZStandard
104->Xmax
~72->Ymin
ZInteger
real(12,3,0,0,94,61,1
41->A:Ans->E
29->B:Ans->F
1->H:0->V
5->S:0->theta
0->D
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 D or K=45
   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
      1->D
      A
      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:1->D
      B
      Pt-On(A,~Ans,2
      Pxl-Off(Ans-V,A
      Pxl-Off(Ans-2V,A
   End
   If D
   Goto SQ
   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
      Pxl-On(62,theta
      theta+1->theta
      If Ans=95
      1->D
      S+3->S
   End
   If D
   Goto SQ
   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
Lbl SQ:End


The only problem is that makes the game slower. If you were to run the original game and this game back-to-back, you can definitely tell a difference. Is there a faster way to do this so it doesn't affect performance? There are no memory leaks in this program. (This is programmed in Source Coder 3 on Cemetech, so ignore if some parts of the code if it looks funny. ~'s are negatives, and -> is the Store (→) character. theta is θ)
I’m not sure what you’ve modified here, and I’m also not familiar with Nibbles. Did you write both of these? Also, what do you mean by “exits outside the program”? I don’t see any particularly jarring differences between the two programs besides a few drawing commands that are there in the first and missing in the second, and some Gotos. I think everyone needs some backstory before we can help you.

If this is a program you’ve already posted here, you can just include a link to it in your original post.
The original Nibbles concept does not belong to me. The original game belongs to another user on TI-Basic developer. The game has four conditions where it checks if the user crashed or pressed CLEAR. The game ends inside the program, and I'm wanting it to end outside the program (After the End Statements). Setting boolean variables and gotos make the program slower. I'm wondering how I can make it faster than it is.

Note:

I may not be on Cemetech for a bit. Who knows, maybe a while. I'm turning in the school Chromebook tomorrow so I won't be able to use any Chromebook till next school year. If I am on a computer during the next three months, then I'll post updates.
  
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 GMT - 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