1

I am trying to create a game similar to doom on my ti-84 plus ce using pure ti-basic, and I have tried several raycasting codes, but most throw up multiple errors, and the ones that dont error are incredibly slow and dont actually do things or are very inconsistent. The most common error is ERROR: INVALID DIMENSION, which usually occurs after one frame is drawn (so 20 seconds or so). I guess there are a few things I am asking: How should I go about making a usable raycasting program? (Examples of code please). How can I optimize programs to make them as fast as possible? Below are the three codes I used to try to do raycasting, 2 made by iPhoenix and one made by Vaelus. I have been working on my own but i am fairly busy with school and such so it is slow.

4→Xmin
24*4+3→Xmax
-1→Ymin
1→Ymax
1.5→S
1.5→T
dim([A])→L₁
L₁(1)→H
L₁(2)→W
seq((I-12.5)*4°+45°,I,1,24)→L₁
1→R
While R
For(I,1,24)
0→C
S→U
T→V
0→D
While C=0 and 1≤int(U) and int(U)≤W and 1≤int(V) and int(V)≤H
L₁(I)→A
If A>0°:Then
If A>90°:Then
-int(-U-1)→P
int(V+1)→Q
Else
int(U+1)→P
int(V+1)→Q
End
Else
If A>-90°:Then
int(U+1)→P
-int(-V-1)→Q
Else
-int(-U-1)→P
-int(-V-1)→Q
End
End
If abs((P-U)/cos(A))<abs((Q-V)/sin(A)):Then
D+abs((P-U)/cos(A))→D
V+(P-U)*tan(A)→V
P→U
Else
D+abs((Q-V)/sin(A))→D
U+(Q-V)/tan(A)→U
Q→V
End
If int(U)≥1 and int(U)≤W and int(V)≥1 and int(V)≤H:Then
If [A](int(U),int(V))
1→C
End
If -int(-U+1)≥1 and -int(-U+1)≤W and -int(-V+1)≥1 and -int(-V+1)≤H:Then
If [A](-int(-U+1),-int(-V+1))
1→C
End
End
I*4→N
Line(N,1,N,-1,0)
Line(N+1,1,N+1,-1,0)
Line(N+2,1,N+2,-1,0)
Line(N+3,1,N+3,-1,0)
If C:Then
tan⁻¹(([A](int(U),int(V))+[A](-int(-U+1),-int(-V+1)))/D)/32°→Z
Line(N,Z,N,-Z)
Line(N+1,Z,N+1,-Z)
Line(N+2,Z,N+2,-Z)
Line(N+3,Z,N+3,-Z)
End
End
getKey→K
(L₁(12)+L₁(13))/2→F
If K=25:Then
S+0.1*cos(F)→S
T+0.1*sin(F)→T
End
If K=34:Then
S-0.1*cos(F)→S
T-0.1*sin(F)→T
End
If K=24:Then
L₁+2°→L₁
End
If K=26:Then
L₁-2°→L₁
End
If K=45
0→R
End
0→Xmin
{BLACK,DARKGRAY,GRAY,MEDGRAY,LTGRAY,WHITE,WHITE→L₁
70→Xmax
-20→Ymin
20→Ymax
90→θ
310→R
119→S
219→T
For(A,1,51,-1
For(B,1,100,50
Pxl-On(163-A,263-B,GRAY
Pxl-On(163-B,263-A,GRAY
Pxl-On(164-A,264-B,GRAY
Pxl-On(110+A,210+B,MEDGRAY
Pxl-On(110+B,210+A,MEDGRAY
Pxl-On(109+B,209+A,MEDGRAY
Pxl-On(109+A,209+B,MEDGRAY
End
End

For(A,1,10
For(B,1,10
If [A](A,B
Then
For(C,1,5
For(D,1,5
Pxl-On(110+(5A-4+C),210+(5B-4+D),BLACK
End
End
End
End
End
Repeat Ans
For(A,­6,13.5,.45
Line(Xmin,A,Xmax,A,WHITE
End

DelVar N
Pxl-Off(S,T
For(A,70-R,1-R,-­1
N+1→N
DelVar C
cos(A→P
sin(A→Q
Repeat K=45 or C>20
C+1→C
pxl-Test(int(S+CP),int(T+CQ
End
If C<20:Then
int(C/3→V
int(40/C)/2→W
If W>4
4→W
For(B,­-W,W
For(D,1,2
Pt-On(N,B,D,L₁(V
End
End
End
End
Pxl-On(S,T
Repeat Ans
getKey
End
Pxl-Off(S,T
Ans→K
If K=24
R-45→R
If K=26
R+45→R
R-220→θ
If K=25
Then
int(S-3cos(θ→S
int(T+3sin(θ→T
Else
If K=34
Then
int(S+3cos(θ→S
int(T-3sin(θ→T
End
End
Pxl-On(S,T
Pause
End
ZStandard
ZSquare
GridOff
AxesOff
LabelOff
BorderColor 4
BackgroundOff
{Black,DarkGray,Gray,MedGray,LtGray->L1
For(A,1,10
   For(B,1,10
      If [A](A,B
      Then
         For(C,1,5
            For(D,1,5
               Pxl-On(115+5A-C,5B-D,Black
            End
         End
      End
   End
End
122->A
5->B
DelVar DRepeat K=45
   For(theta,~3,3,.1
      Line(12+theta,3,12+theta,10,0
   End
   Circle(12,6,1.8,Black
   Line(10,6,14,6,1,Black,1
   Line(12,4,12,8,1,Black,1
   For(theta,~40+D,40+D
      If not(remainder(abs(theta-D),10
      Line(12+2.5cos(theta-2D),6+2.5sin(theta-2D),12+2cos(theta-2D),6+2sin(theta-2D),1,Red+(theta=D),1
      sin(theta->U
      cos(theta->V
      DelVar NRepeat Ans or N=10
         N+1->N
         int(A+NU->I
         int(B+NV->J
         pxl-Test(I,Ans
      End
      (theta-D)/5
      Line(Ans,5,Ans,~5,0
      If N!=10
      Line(Ans,(10-N)/2,Ans,~(10-N)/2,1,L1(1+min(int(N/2),dim(L1
   End
   If not(pxl-Test(A,B
   Pxl-On(A,B,Red
   getKey
   Repeat Ans
      getKey
   End
   Ans->K
   Pxl-Off(A,B
   D-5(K=11->D
   D+5(K=15->D
   D-2(K=12->D
   D+2(K=14->D
   int(A+(K=13)2sin(D)+(K=23)5sin(D->A
   int(B+(K=13)2cos(D)+(K=23)5cos(D->B
End
RecallGDB 0```
Zenedus
  • 96
  • 9
  • First step in speed optimization: Don't calculate sines and cosines inside a loop; store them in a second table. I doubt you'll get more than 2 FPS in an optimized game, but try asking on the forum Cemetech; there are quite a few people who know TI-BASIC well. – lirtosiast Jul 31 '19 at 09:57

0 Answers0