I programmed pong into my TI-83 seemingly correctly but when I play it it gives me the "game over" screen when the ball hits the paddle. Is it supposed to do this? Where did I go wrong? Here's a link to pictures of the code.

https://image.ibb.co/frJupd/IMG_20180614_110844_807.jpg
https://image.ibb.co/iwPOhy/IMG_20180614_111009_314.jpg
https://image.ibb.co/di3S9d/IMG_20180614_111128_884.jpg
https://image.ibb.co/fqJihy/IMG_20180614_111229_780.jpg

I numbered them Smile
It is very hard to read the code photographed, written out on a calculator...
It might be possible that K is already 45, since you don't initialize it at the beginning, which would bring up the game over screen, but that would be when you start the game, rather than when you hit a paddle. Another thing that I find weird is that you only bring up the game over screen if the left paddle misses, but not the right, is this supposed to be played against a wall?
The logic seems good though.
Yes, it is supposed to be played against a "wall" because I don't think there's a way to control two paddles and if there is that seems a little out of my league to program considering this is the first time I've tried. How would I go about initializing K in the beginning? Where would I add it and what would the code be? I'm hoping that that's the problem and could be a simple fix.
Technicaly all letter variables in BASIC are already initialized. You just have to store a value in it.
Add
0->K
To the first line of your program. (Replace -> with the sto arrow)
TheLastMillennial wrote:
Technicaly all letter variables in BASIC are already initialized. You just have to store a value in it.
Add
0->K
To the first line of your program. (Replace -> with the sto arrow)

Well actually that’s not necessary. The repeat loop always runs at least once, and within it, the getKey already stores a 0 in K. So a 0->K at the beginning is redundant.

Also, for all of our sakes, here is the code from the pictures:

Code:
3->A:4->X
1->S:1->T
randInt(1,8->Y
Repeat K=45 or X=1 and A!=Y
ClrHome
Output(A,1,”[
Output(Y,X,”O
getKey->K
max(1,min(8,A+(Ans=34)-(Ans=25->A
T(Y>1 and Y<8)+(Y=1)-(Y=8->T
S(X>1 and X<16)+(X=1)-(X=16->S
X+Ans->X:Y+T->Y
End
Pause “GAME OVER!
ClrHome:”
sorry I didn't have a way to transfer the code over in text maybe I can crop the photos next time? I was on the bus but I'll keep it it mind. So if k->0 isn't the answer, what do I do?
Well I can’t test anything right now, but it looks like your main problem is that T and S only ever change between 1 and 2. What you need to do is if the ball hits a boundary, it stores negative T or negative S in that same variable. This should make the ball “bounce” off whatever wall it hits.
fixed it! thank you for your help everyone
  
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