I came across this 1-year old post about an awesome raycasting engine written entirely in TI-Basic, I've been reading over the code for a few hours now and there are some errors preventing it from running correctly. I would love to get it working because this seems like a great way for me to better understand the concepts of raycasting and implementation. Here's a link to the original post (https://www.cemetech.net/forum/viewtopic.php?t=13579) and here's the code
Code:
Here is where I'm at with it:
First off It doesn't clear the graph screen or turn off the axis, leaving it with a messy look, So the first thing I did was add those commands.
For Variables, S and T are the x,y corrdinents of the players pxl on the minimap(Not sure which ones which atm)
R is for raycast? Later on, it is subtracted from some numbers for some reason, and those numbers are responsible for shootin' out them rays.
Code:
This Right here just draws the mini-map in the bottom right corner and where I believe the first error is, Shouldn't it be For(A,1,51) instead of For(A,1,51,-1)? I delete the -1 and this part of the code works correctly.
The next 4 lines,
Code:
Draw white lines from the top of the minimap to about 3/4ths of the way up the screen. I think this is to clear what is shown once raycast projection is shown and redrawn with movement, But I haven't gotten that working so right now it's useless.
Code:
Here is where the fun happens! (And all my problems)
For(A,70-R,1-R,-1) ; Here is where I said R was subtracted from numbers for some reason.
A is used to create P & Q, which is used in the piece of code I think is broken.
Code:
This pxl-Test is shooting the rays from the player, sweeping across about a 60° angle, and testing to see what pixels are black and what pixels are white. But this isn't used for anything! its just there?
The code afterward draws the raycast projection, but only if C is less than 20? But the loop above only terminates once C greater than 20?
Hoping someone else smarter than me can fix this because I'm stumped (Also I've never built a raycast So I don't know what to do to begin with )
Code:
Degree
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
Here is where I'm at with it:
First off It doesn't clear the graph screen or turn off the axis, leaving it with a messy look, So the first thing I did was add those commands.
For Variables, S and T are the x,y corrdinents of the players pxl on the minimap(Not sure which ones which atm)
R is for raycast? Later on, it is subtracted from some numbers for some reason, and those numbers are responsible for shootin' out them rays.
Code:
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
This Right here just draws the mini-map in the bottom right corner and where I believe the first error is, Shouldn't it be For(A,1,51) instead of For(A,1,51,-1)? I delete the -1 and this part of the code works correctly.
The next 4 lines,
Code:
Repeat Ans
For(A,6,13.5,.45
Line(Xmin,A,Xmax,A,WHITE
End
Draw white lines from the top of the minimap to about 3/4ths of the way up the screen. I think this is to clear what is shown once raycast projection is shown and redrawn with movement, But I haven't gotten that working so right now it's useless.
Code:
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
Here is where the fun happens! (And all my problems)
For(A,70-R,1-R,-1) ; Here is where I said R was subtracted from numbers for some reason.
A is used to create P & Q, which is used in the piece of code I think is broken.
Code:
Repeat K=45 or C>20
C+1→C
pxl-Test(int(S+CP),int(T+CQ
End
This pxl-Test is shooting the rays from the player, sweeping across about a 60° angle, and testing to see what pixels are black and what pixels are white. But this isn't used for anything! its just there?
The code afterward draws the raycast projection, but only if C is less than 20? But the loop above only terminates once C greater than 20?
Hoping someone else smarter than me can fix this because I'm stumped (Also I've never built a raycast So I don't know what to do to begin with )