This is code for snake:

But it is very confusing to me!


Code:
:26→K
:1.1→B
:{4Ans→A
:ClrHome
:For(A,1,E2
:randInt(1,16)+.1randInt(1,8→C
:Repeat C=Ans(1
:A→dim(⌊A
:⌊A(1
:Output(10fPart(Ans),int(Ans),"O
:Output(10fPart(B),int(B),"   // 1 space
:Output(10fPart(C),int(C),"*
:getKey
:If Ans=45
:Goto 0
:If Ans=34 or 2>abs(Ans-25
:Ans→K
:⌊A(A→B
:⌊A(1)+(K=26)-(K=24)+.1((K=34)-(K=25
:If max(LA=Ans
:Goto 0
:Ans+16(not(int(Ans))-(17=int(Ans)))+.8(not(fPart(Ans))-(.9=fPart(Ans
:augment({Ans},⌊A→A
:End
:augment(Ans,{Ans(A→A
:End
:Lbl 0
:ClrHome
:A



This code is very confusing to me!!

I was wondering if anyone would tell me what all of this means!?

If not, then just tell me what line #3 means. It is all very confusing!
You're missing a list token on line 3 before the A.
Basically, that line generates the list {4.4} and stores it into list A. It saves one byte by multiplying 4 and 1.1 together rather than just putting 4.4
It looks like list A is the coordinates of the body of the snake, with the first number as the head and the last as the tail.
All coordinates are stored with the integer part (before the decimal) corresponding to the X axis, and the fractional part (after the decimal) corresponds to the Y axis.
C is the coordinate of the dot that gives you a point.
The number A is the length of the snake, which is used for the score.
B is the coordinate of the snake part to be removed.
K is used to keep track of which key is pressed.
Goto 0 is used for a game over.
If you want to learn TI-BASIC, I recommend reading Kerm's book, it's where I learned TI-Basic, and it helps a lot. There are multiple extremely good websites for learning TI-BASIC programming, too.
  
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