Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Source code for a TI-BASIC implementation of Snake
{11,5,11,5,11,5→L₁
1→𝒏:dim(L₁)→L
1→S:0→T
0→C:1→P
0→W
DelVar [A]
{10,26→dim([A]
ClrHome
While 1
If P
Then
0→P
randInt(W+2,25-W→A
randInt(1,10→B
While [A](B,A
randInt(W+2,25-W→A
randInt(1,10→B
End
Output(B,A,"*
End
getKey→PV
If PV=26 and S≠⁻1
Then
1→S
0→T
Else
If PV=24 and S≠1
Then
⁻1→S
0→T
Else
If PV=34 and T≠⁻1
Then
0→S
1→T
Else
If PV=25 and T≠1
Then
0→S
⁻1→T
End
End
End
End
If T
randInt(1,10,3
If PMT=A and FV=B
Then
C+1→C
If 𝒏≠L-1
Then
L→dim(L₂
For(I,1,L)
remainder(𝒏+I+1,L
If Ans=0
L
L₁(Ans→L₂(I
End
L₂→L₁
End
L-1→𝒏
L+2→L
L→dim(L₁
L₁(L-3→L₁(L-1
L₁(L-2→L₁(L
1→P
If remainder(C,10)=0
Then
W+1→W
For(I,1,10
Output(I,W,"X
Output(I,27-W,"X
End
End
End
remainder(𝒏+2,L→𝗡
If not(P) and abs(L₁(𝗡)-13.5)<13.5-W
Then
0→[A](L₁(𝗡+1),L₁(𝗡
Output(L₁(𝗡+1),L₁(𝗡),"
End
L₁(𝒏)+S→L₁(𝗡
L₁(𝒏+1)+T→L₁(𝗡+1
L₁(𝗡→PMT
L₁(𝗡+1→FV
If abs(FV-5.5)>4.5 or abs(PMT-13.5)≥13.5-W
Goto D
If [A](FV,PMT
Goto D
Output(FV,PMT,"0
1→[A](FV,PMT
𝗡→𝒏
End
Lbl D
ClrHome
6→dim(⌊SNKHS
6→dim(⌊SNKDT
C→⌊SNKHS(6
getDate
100fPart(Ans(1)/100)+10000Ans(2)+100Ans(3→⌊SNKDT(6
SortD(⌊SNKHS,⌊SNKDT
5→dim(⌊SNKHS
Output(2,5,"*****************
Output(3,5,"* HIGH SCORES *
For(I,1,5
Output(I+3,5,"* . *"
Output(I+3,7,I
If ⌊SNKHS(I)
Output(I+3,10,⌊SNKHS(I
If ⌊SNKDT(I)=0 or ⌊SNKHS(I)≥10000
Then
Else
If ⌊SNKDT(I)<100000
Then
Output(I+3,14,"0
Output(I+3,15,⌊SNKDT(I
Else
Output(I+3,14,⌊SNKDT(I
End
End
End
Output(9,5,"*****************
DelVar L:DelVar S
DelVar P:DelVar T
DelVar C:DelVar I
DelVar A:DelVar B
DelVar 𝒏:DelVar [A]
0→𝗡:0→PV:0→PMT:0→FV
0→dim(L₁
0→dim(L₂
Disp "","","","","","","","
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.