I was reading Kerm's Book on coding the ti 83/84, and saw the cheese game exercise. I wanted to modify it to work better on the ti 84 plus CE, however, while I was trying to figure out how to do it, I created a bug that I don't know how to fix. The program uses "=" on the side of the screen as hunger bars. They are supposed to reset when you eat a cheese by touching it. However, all my program does it move up all of the "=" by one. I tried going through each line of my code, but I still don't know what I did. I'm sure it will be very obvious once pointed out. Thanks.

Code:

7->A:7->B
0->H:0->S
Repeat H>=8 or K=45
   randInt(1,23->C
   randInt(1,10->D
   ClrHome
   Output(D,C,"^^2
   For(X,1,int(H
      Output(8-X,24,"=
   End
   Repeat H>=8 or K=45 or (C=A and B=D)
      If H=int(H
      Output(9-H,24,"=
      Output(B,A,"M
      getKey->K
      If K
      Output(B,A,"
      If K=24 and A>1
      A-1->A
      If K=26 and A<24
      A+1->A
      If K=25 and B>1
      B-1->B
      If K=34 and B<9
      B+1->B
      If S<10
      H+.1->H
      If S>10
      H+.2->H
      If S>20
      H+.25->H
   End
End
If C=A and B=D
Then
0->H
S+1->S
End
Output(3,1,"------------
Output(4,1," YOU ATE
Output(4,10,S
Output(5,1,"PIECIES OF CHEESE
Output(6,1,"------------
Pause
ClrHome

Here is the original (I think)

Code:

7→A:7→B
0→H:0→S
Repeat H≥8 or K=45
randInt(1,15→C
randInt(1,8→D
ClrHome
Output(D,C,"▫
For(X,1,int(H
Output(16-X,25,"=
End
Repeat H≥10 or C=A and B=D
If H=int(H
Output(10-H,16,"=
Output(B,A,"M
getKey→K
If K
Output(B,A,"
If K=24 and A>1
A-1→A
If K=26 and A<15
A+1→A
If K=25 and B>1
B-1→B
If K=34 and B<8
B+1→B
If S<10
H+.1→H
If S>10
H+.2→H
If S>20
H+.25→H
End
If C=A and B=D
Then
0→H
S+1→S
End:End
Output(3,1,"­­­­­­­­­­­­
Output(4,1," YOU ATE
Output(4,10,S
Output(5,1,"PIECIES OF CHEESE
Output(6,1,"­­­­­­­­­­­­
Pause
ClrHome
Restart, back to the code in his book. This is a really simple change.

Using the logic explained in his book, apply the knowledge that the CE's screen is 10 characters tall and 26 characters wide, and the screen his program is designed for is 8 characters tall and 16 characters wide, this is not a difficult change Smile

Here's my code:

Code:
7->A:4->B
DelVar HDelVar S
Repeat H>=8 or K=45
   randInt(1,25->C
   randInt(1,10->D
   ClrHome
   Output(D,C,"plotsquare
   For(X,1,int(H
      Output(10-X,26,"=
   End
   Repeat H>=8 or K=45 or (C=A and B=D
      If H=int(H
      Output(8-H,16,"=
      Output(B,A,"M
      getKey->K
      If K
      Output(B,A,"
      If K=24 and A!=1
      A-1->A
      If K=26 and A!=25
      A+1->A
      If K=25 and B!=1
      B-1->B
      If K=34 and B!=10
      B+1->B
      H+.2->H
   End
   If C=A and B=D
   Then
      DelVar HS+1->S
   End
End
"---
For(A,1,3
Ans+Ans
End
Ans+"--
Output(3,1,Ans
Output(4,1," YOU ATE
Output(4,10,S
Output(5,1,"PIECES OF CHEESE
Output(6,1,Ans
Pause
ClrHome


I haven't tested it, but it should work. I did a few "bonus" optimizations, too.
Kerm has a book?! What's it called, and where can I buy it?
it's called "Programming the TI-83 Plus/TI-84 Plus", and I'm fairly proud of it. Smile I also have another book, called "Using the TI-84 Plus", that's more focused on using the calculators for math and science.
A bit off-topic, but I was legitimately going to post my code for a CE-compatible Mouse+Cheese game, but then I scrolled up and saw that I already did that a few months ago.
  
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