Skip to content

Instantly share code, notes, and snippets.

@briangordon
Created October 3, 2019 05:51
Show Gist options
  • Save briangordon/edbb3f317fc34b3dea18c376eb5acb05 to your computer and use it in GitHub Desktop.
Save briangordon/edbb3f317fc34b3dea18c376eb5acb05 to your computer and use it in GitHub Desktop.
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