-3

I am trying to create Frogger in a calculator, but when the program runs, it ends before it completes the game. Anyone know TI Basic?

 :Menu("FROGGER","START",S,"QUIT",Q 
:Lbl Q 
:ClrHome 
:Pause "BYE 
:ClrHome 
:Output(1,1," 
:Return
:Lbl S 
:ClrHome 
:‾1→S 
:Lbl 1 
:ClrHome 
:S+1→S 
:8→A
:8→B
:randInt(3,14→C 
:randInt(3,14→D 
:randInt(3,14→E 
:randInt(3,14→F 
:randInt(3,14→G 
:randInt(3,14→H 
:While 1
:getKey→K 
:If max(K=24,25,26,34 
:Output(A,B,"  
:Output(2,C+1,"  
:Output(3,D+1,"  
:Output(4,E+1,"  
:Output(5,F+1,"  
:Output(6,G+1,"  
:Output(7,H+1,"  
:For(N,1,7 
:Output(N,1,"  
:End 
:A-(K=25)(A>1)+(K=34)(A<8→A 
:B-(K=24)(B>3)+(K=26)(B<14)→B 
:Output(A,B,"^ 
:Output(2,C,"< 
:Output(3,D,"< 
:Output(4,E,"< 
:Output(5,F,"< 
:Output(6,G,"< 
:Output(7,H,"< 
:C-1→C 
:D-1→D 
:E-1→E 
:F-1→F 
:G-1→G 
:H-1→H 
:If not(C 
:14→C 
:If not(D 
:14→D 
:If not(E 
:14→E 
:If not(F 
:14→F 
:If not(G 
:14→G 
:If not(H 
:14→H 
:If A=2 and B=C or A=3 and B=D or A=4 and B=E or A=5 and B=F or A=6 and B=G or A=7 and B=H:Goto 2 
:If A=1 
:Goto 1 
:End 
:Lbl 2 
:ClrHome 
:Disp "SCORE:",S 
:Pause 
:ClrHome 
:Output(1,1," 
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar KDelVar S

It runs correctly up until you click start, at which point it ends and displays the score. I don't know which part specifically is wrong.

2 Answers2

1

Your While loop is exiting at the Goto 2, so I think your If statement is wrong. I can't possibly imagine all those and and or next to each other working properly; try putting in parentheses separating them.

For example, If (A=2 and B=C) or (A=3 and B=D) or (A=4 and B=E) instead of If A=2 and B=C or A=3 and B=D or A=4 and B=E.

Also, next time, please explain your code and all the variables you used. It's generally frowned upon to just dump your raw code and ask "why is it not working."

user3932000
  • 671
  • 8
  • 24
0

I manually regexed the code so it could fit into SourceCoder, and got this .8xp. There's a small error in line 24:

:If max(K=24,25,26,34

should be

:If max(K={24,25,26,34 

Apart from that, the code seems to work fine, though its code style and speed could be improved.

If you want tips on how to improve the game, consider making a post on Code Review.

Community
  • 1
  • 1
lirtosiast
  • 592
  • 4
  • 15