Fun Tetris Project
Shlayne 28 Dec 2018 01:12
I was bored, so I just made a little something. I know Tetris has already been released to the public many times, but from what I can see, they don't have all of the features. I wanted to have a version of Tetris (on any calc really) that had most, if not all the features of the original Tetris, even if it runs slowly. It is completely self-contained, and has some subprograms at the end. I know I still need a TON of optimizations, but here's what I came up with:
ClrHome
StoreGDB 1
AxesOff
FnOff
ClrDraw
0→Xmin
94→Xmax
0→Ymin
62→Ymax
Vertical 31
Vertical 64
Line(32,0,63,0
Text(0,0,"Next
Text(6,0,"Piece:
Text(29,0,"Hold:
Text(0,66,"Score:
Text(12,66,"High:
Text(24,66,"Level:
Text(36,66,"Lines:
For(θ,0,23,23
Line(0,49-θ,15,49-θ
Line(15,49-θ,15,34-θ
Line(15,34-θ,0,34-θ
Line(0,34-θ,0,49-θ
End
DelVar [A]
{21,12→dim([A]
For(B,1,21
1→[A](B,1
1→[A](B,12
End
For(A,2,11
1→[A](21,A
End
SetUpEditor TH
UnArchive ⸤TH
If not(dim(⸤TH
{0→⸤TH
0→Z
1→R
0→T
0→W
20→J
SetUpEditor L₃
DelVar L₃0→Q
randInt(1,7→P
Repeat K=45 or Q
If T=1 and not(C
1→Q
For(I,0,1
If not(I
Goto GP
End
Ans→[B]
dim(Ans→L₁
For(I,0,1
If not(I
Goto GB
End
randInt(1,7→P
For(I,0,1
If not(I
Goto GP
End
Ans→[C]
dim(Ans→L₂
For(I,0,1
If not(I
Goto SN
End
6→S
1→T
0→X
0→C
0→G
Repeat K=45 or G or Q
Text(6,66,Z
Text(18,66,⸤TH(1
Text(30,66,R
Text(42,66,W
For(I,0,1
If not(I
Goto SC
End
getKey→K
If K=105
Then
Text(57,0,"Paused
Pause
"
Text(57,0,Ans+Ans
End
If K=34 or X>9
Then
If X>9
0→X
If K=34
Z+1→Z
For(I,0,1
If not(I
Goto EC
End
1→θ
For(A,1,L₁(2
If [A](T+⸤BB(A),S+A-1
0→θ
End
T+θ→T
not(θ→G
End
If K=21
Then
For(I,0,1
If not(I
Goto EC
End
1→G
0→H
1→θ
While θ
For(A,1,L₁(2
If [A](T+⸤BB(A),S+A-1
0→θ
End
If θ
Then
T+1→T
H+1→H
End
End
Z+2H→Z
For(I,0,1
If not(I
Goto SC
End
End
If K=26
Then
For(I,0,1
If not(I
Goto EC
End
1→θ
For(B,1,L₁(1
If [A](T+B-1,S+⸤RB(B
0→θ
End
S+θ→S
End
If K=24
Then
For(I,0,1
If not(I
Goto EC
End
1→θ
For(B,1,L₁(1
If [A](T+B-1,S-2+⸤LB(B
0→θ
End
S-θ→S
End
If K=11 or K=15
Then
If not(21<T+L₁(2) or 12<S+L₁(1
Then
If 5=sum(L₁
Then
If K=15
rowSwap([B],1,L₁(1))^^T^^ //^^T^^ is the transpose character
If K=11
rowSwap([B]^^T^^,1,L₁(2 //^^T^^ is the transpose character
Ans→[E]
dim(Ans→L₅
1→θ
For(B,1,L₅(1
For(A,1,L₅(2
If [A](T+B-1,S+A-1) and [E](B,A
0→θ
End
End
If θ
Then
For(I,0,1
If not(I
Goto EC
End
[E]→[B]
L₅→L₁
For(I,0,2
If not(I
Goto GB
If I=1
Goto SC
End
End
End
End
End
If K=91 and not(C
Then
1→C
For(I,0,1
If not(I
Goto EC
End
If dim(L₃
Then
For(B,1,L₃(1
For(A,1,L₃(2
If [D](B,A
Pt-Off(3A,26-3B,2
End
End
[B]→[E]
[D]→[B]
[E]→[D]
Else
For(I,0,1
If not(I
Goto EN
End
[B]→[D]
[C]→[B]
randInt(1,7→P
For(I,0,1
If not(I
Goto GP
End
Ans→[C]
dim(Ans→L₂
For(I,0,1
If not(I
Goto SN
End
End
dim([B]→L₁
dim([D]→L₃
For(I,0,1
If not(I
Goto GB
End
For(B,1,L₃(1
For(A,1,L₃(2
If [D](B,A
Pt-On(3A,26-3B,2
End
End
6→S
1→T
End
If G
Then
If T<J
T→J
For(B,1,L₁(1
For(A,1,L₁(2
If [B](B,A
Then
1→[A](T+B-1,S+A-1
25+3A+3S→N
66-3B-3T→O
Pt-On(N,O,1
Pt-On(N,O,2
End
End
End
0→θ
L₁(1→dim(⸤C
Fill(0,⸤C
For(B,T,T-1+L₁(1
Matr>list([A]^^T^^,B,L₄ //^^T^^ is the transpose character
If not(sum(not(L₄
Then
B→⸤C(B-T+1
θ+1→θ
For(A,2,11
0→[A](B,A
End
[A]
For(A,B,J,-1
rowSwap(Ans,A,A-1
End
Ans→[A]
End
End
SortD(⸤C
Z+R(80(θ=1)+|E2(θ=2)+200(θ=3)+400(θ=4→Z
If Ans>⸤TH(1
Ans→⸤TH(1
W+θ→W
1+int(W/10→R
If θ
Then
Text(57,0,"Clearing
For(B,⸤C(1),J,-1
For(A,2,11
28+3A→N
63-3B→O
If [A](B,A
Then
Pt-On(N,O,1
Pt-On(N,O,2
Else
Pt-Off(N,O,1
Pt-Off(N,O,2
End
End
End
"
Ans+Ans
Text(57,0,Ans+Ans
J+θ→J
End
End
X+R→X
End
For(I,0,1
If not(I
Goto EN
End
End
Archive ⸤TH
RecallGDB 1
DelVar GDB1DelVar ADelVar BDelVar CDelVar GDelVar HDelVar IDelVar JDelVar KDelVar NDelVar ODelVar PDelVar QDelVar RDelVar SDelVar TDelVar WDelVar XDelVar YDelVar ZDelVar θDelVar [A]DelVar [B]DelVar [C]DelVar [D]DelVar [E]DelVar L₁DelVar L₂DelVar L₃DelVar L₄DelVar L₅DelVar ⸤CDelVar ⸤BBDelVar ⸤LBDelVar ⸤RB
AxesOn
ClrHome
Return
Lbl EC
For(B,1,L₁(1
For(A,1,L₁(2
If [B](B,A
Pt-Off(25+3A+3S,66-3B-3T,2
End
End
End
Lbl EN
For(B,1,L₂(1
For(A,1,L₂(2
If [C](B,A
Pt-Off(3A,49-3B,2
End
End
End
Lbl GB
L₁(2→dim(⸤BB
Fill(0,⸤BB
L₁(1→dim(⸤LB
Fill(0,⸤LB
⸤LB→⸤RB
For(B,L₁(1),1,-1
For(A,1,L₁(2
If [B](B,A) and not(⸤BB(A
B→⸤BB(A
End
End
For(B,1,L₁(1
For(A,L₁(2),1,-1
If [B](B,A) and not(⸤RB(B
A→⸤RB(B
End
End
For(B,1,L₁(1
For(A,1,L₁(2
If [B](B,A) and not(⸤LB(B
A→⸤LB(B
End
End
End
Lbl GP
If P=1
[[1,1][1,1
If P=2
[[1][1][1][1
If P=3
[[0,1,0][1,1,1
If P=4
[[1,0][1,0][1,1
If P=5
[[0,1][0,1][1,1
If P=6
[[1,0][1,1][0,1
If P=7
[[0,1][1,1][1,0
End
Lbl SC
For(B,1,L₁(1
For(A,1,L₁(2
If [B](B,A
Pt-On(25+3A+3S,66-3B-3T,2
End
End
End
Lbl SN
For(B,1,L₂(1
For(A,1,L₂(2
If [C](B,A
Pt-On(3A,49-3B,2
End
End
End