As I promised, I have competely improved Josh Frisby's JDodge19. Some notable improvements are the complete elimination of Lbls/Gotos. As a result, the game is now considerably faster. I have also streamlined the game engine, and improved the save feature. I removed options which weren't necessary. I added Mirage compatibility. The changes you will notice immediately are the graphical menus and new characters, which wouldn't have been possible without Kerm's Symbols and Elfprince13's Stat Sprite. The structure of the problem is similiar to how I plan to build Battleship. If anyone can suggest further improvements, I would appreciate that. If anyone can figure out why, in the game, the right wall slowly disappears, I would appreciate that as well. If I have enough time, I plan to make the menu with a sprite of JDonals, a spoof of Ronald McDonald from Frisby's forums, pointing at the different options. Now the good part, the code! First the original code:


Code:
:0→G
:If D≠1
:Goto BB
:If D=1
:Goto SS
:Lbl BB
:ClrHome
:Input "Enter your name.",Str1
:If G=1
:Goto SS
:If G≠1
:Goto A
:Lbl A
:0→D
:0→G
:ClrHome
:Menu("     JDODGE     ","PLAY GAME",B,"INFO",C,"CHEATS",CH,"CHANGE NAME",BB,"CALCULATE TIME",CT,"CONTINUE GAME",CG,"QUIT",D
:End
:Lbl D
:0→D
:ClrDraw
:ZStandard
:AxesOn
:ClrHome
:Output(1,1,""
:Stop
:End
:Lbl C
:ClrHome
:Disp "Created by:"," Josh","  Frisby
:Pause
:ClrHome
:Disp "For more JGames","go to:","","www.freewebs.com","/sadmeal
:Pause
:ClrHome
:Disp "Join the JGames","Forums to chat","with other","members.
:Pause
:If G=1
:Goto SS
:If G≠1
:Goto A
:Goto A
:End
:Lbl B
:6→A
:0→S
:2→E
:2→N
:2→Q
:2→C
:2→P
:2→V
:2→T
:0→U
:1→L
:Lbl SS
:ClrHome
:Output(4,4,"DODGE
:For(θ,1,8
:Output(θ,1,"!
:Output(θ,11,"!
:End
:For(θ,12,16
:Output(1,θ,"=
:Output(5,θ,"=
:Output(6,θ,"=
:Output(8,θ,"=
:End
:Output(2,12,"TIME
:Output(3,12,"ALIVE
:Output(4,4,"DODGE
:1→D
:Output(4,4,"     
:Lbl Z3
:1→G
:0→U
:Repeat A=U
:getKey→K
:A→B
:If S≥1000
:Output(4,12,S
:If S<1000
:Output(4,13,S
:If L=1
:Output(7,12,"DODGE
:If K=21
:Pause
:If K=22
:Menu("     OPTIONS    ","CONTINUE",Z3,"MAIN MENU",A,"INFO",C,"CHEATS",CH,"CHANGE NAME",BB,"SAVE AND QUIT",FG,"QUIT",D
:If K=15
:Goto JJ
:A-1(K=24)+1(K=26)→A
:If A=1
:10→A
:If A=11
:2→A
:Output(8,B,"
:Output(8,A,"A
:Output(1,E,"
:Output(2,T,"
:Output(3,N,"
:Output(4,Q,"
:Output(5,C,"
:Output(6,V,"
:Output(7,P,"
:P→U
:V→P
:C→V
:Q→C
:N→Q
:T→N
:E→T
:randInt(2,10→E
:Output(1,E,"O
:Output(2,T,"O
:Output(3,N,"O
:Output(4,Q,"O
:Output(5,C,"O
:Output(6,V,"O
:Output(7,P,"O
:If L=1 or L=2
:L+1→L
:If L=1 or L=2
:Output(7,12,"     
:If L=3
:1→L
:S+1→S
:End
:Lbl EF
:If F=1
:Goto Z3
:If F≠1
:Goto UV
:End
:Lbl UV
:0→D
:0→G
:Output(8,A,"*
:Output(8,A-1,"*
:Output(8,A+1,"*
:Output(7,A,"*
:Output(8,A+2,"*
:Output(7,A+1,"*
:Output(6,A,"*
:Output(7,A-1,"*
:If A>2
:Output(8,A-2,"*
:For(Y,1,255
:End
:For(Y,1,255
:End
:S→T
:((H)*(((2S)+381+(3S))*(S)))→S
:ClrHome
:Disp Str1,"You scored",S,"points!","","Time Alive=",T
:Pause
:0→F
:1→H
:ClrHome
:Disp "Join the JGames","Forums to","compare your","score with the","world.
:Pause
:Goto A
:End
:Lbl JJ
:For(θ,1,8
:For(Z,1,16
:Output(θ,Z,"*
:End
:End
:Goto A
:End
:Lbl CT
:ClrHome
:Disp "This is only","accurate for","Silvers and","TI-84s.
:Pause
:ClrHome
:Disp "Enter the","number you got","for time alive.
:Input Z
:(Z)/(3.806402823)→T
:ClrHome
:Disp "You played for","about",T,"seconds.
:Pause
:Menu("  CONVERT TO?   ","MINUTES",MM,"HOURS",HH,"MAIN MENU",A
:End
:Lbl MM
:ClrHome
:T/60→Y
:Disp Y,"Minutes.
:Pause
:Goto A
:End
:Lbl HH
:ClrHome
:T/60→Y
:Y/60→Z
:Disp Z,"Hours.
:Pause
:Goto A
:End
:Lbl CH
:ClrHome
:Menu("     CHEATS     ","JOSH MODE",JM,"JOSH MODE OFF",JO,"5X SCORE",5S,"2X SCORE",2S,"RESET SETTINGS",RS,"RETURN",RR,"SAVE AND QUIT",FG
:End
:Lbl RR
:If G=1
:Goto SS
:If G≠1
:Goto A
:Lbl JM
:Output(3,4,"JOSH MODE
:Output(5,4,"ACTIVATED
:1→F
:8→H
:For(I,1,225
:End
:Goto CH
:End
:Lbl JO
:Output(3,4,"JOSH MODE
:Output(5,4,"DISABLED
:0→F
:For(I,1,225
:End
:Goto CH
:End
:Lbl 5S
:Output(3,5,"5X SCORE
:Output(5,4,"ACTIVATED
:5→H
:For(I,1,225
:End
:Goto CH
:End
:Lbl 2S
:Output(3,5,"2X SCORE
:Output(5,4,"ACTIVATED
:2→H
:For(I,1,225
:End
:Goto CH
:End
:Lbl RS
:Output(3,5,"SETTINGS
:Output(5,5,"RESTORED
:1→H
:0→F
:For(I,1,225
:End
:Goto CH
:End
:Lbl CG
:∟JD19(1→G
:∟JD19(2→U
:∟JD19(3→L
:∟JD19(4→T
:∟JD19(5→V
:∟JD19(6→P
:∟JD19(7→C
:∟JD19(8→Q
:∟JD19(9→N
:∟JD19(10→E
:∟JD19(11→S
:∟JD19(12→A
:∟JD19(13→F
:∟JD19(14→H
:Goto SS
:Lbl FG
:G,U,L,T,V,P,C,Q,N,E,S,A,F,H→∟JD19
:ClrHome
:Output(1,1,""
:Stop
Generated by SourceCoder (http://www.cemetech.net/projects/basicelite/sourcecoder.php)
© 2005 Cemetech (http://www.cemetech.net)

Here is my code:
BASIC Code wrote:
::"JDodge - A Dodging Game
:ClrHome
:getkey
:ClrDraw
:AxesOff
:FnOff
:PlotsOff
:GridOff
:LabelOff
:ExprOff
:ZStandard
:Line(‾8,8,8,8
:Line(8,8,8,‾8
:Line(‾8,‾8,‾8,8
:Line(8,‾8,‾8,‾8
:Line(8.3,7.7,8.3,‾8.3
:Line(‾7.7,‾8.3,8.3,‾8.3
:Text(27,10,"JDODGE BY JOSH FRISBY
:For(A,1,200
:End
:For(A,‾.7,1.1,.3
:Line(‾7.7,A,7.7,A,0
:End
:Text(27,24,"OPTIMIZED BY
:For(A,1,200
:End
:For(A,‾.7,1.1,.3
:Line(‾7.7,A,7.7,A,0
:End
:Text(27,20,"ROBERTO SANCHEZ
:For(A,1,200
:End
:ClrDraw
:5,6,7,6,5,4,3,2,1,0,6,5→L1
:0,1,2,2,2,2,2,2,2,2,3,4→L2
:0→∟A(1
:If dim(∟A=1
:12→dim(∟A
:0→Xmin
:0→Ymin
:96→Xmax
:64→YMax
:Repeat C=45 or ((C=21 or C=105) and B=1)
:ClrDraw
:Text(‾1,0,30,"JDODGE
:Text(8,5,"JGAMES ROBERTO SANCHEZ
:Horizontal(47
:Text(24,29,"START GAME
:Text(32,29,"LOAD SAVED DATA
:Text(40,29,"INSTRUCTIONS
:Text(48,29,"ABOUT
:Text(56,29,"QUIT GAME
:StorePic 1
:20→A
:33→B
:Repeat C=21 or C=105 or C=45
:1→dim(L3
:1→dim(L4
:augment(L3,L1+A→L3
:augment(L4,L2+B→L4
:Plot1Scatter ,L3,L4,∙
:RecallPic 1
:Repeat C=21 or C=45 or (C=25 and B≠33) or (C=34 and B≠1)
:getKey→C
:End
:B+8(C=25→B
:B-8(C=34→B
:End:ClrDraw
:PlotsOff
:If (C=21 or C=105) and (B=33 or B=25)
:Then
:If B=25
:Then
:∟A(2→D
:∟A(3→E
:∟A(4→F
:∟A(5→G
:∟A(6→H
:∟A(7→I
:∟A(8→J
:∟A(9→K
:∟A(10→L
:∟A(11→M
:∟A(12→N
:Else
:6→N
:0→M
:2→L
:2→K
:2→J
:2→I
:2→H
:2→G
:2→F
:0→D
:1→E
:End
:ClrHome
:For(O,1,8
:Output(O,1,"!
:Output(O,11,"!
:End
:For(O,12,16
:Output(1,O,"=
:Output(5,O,"=
:Output(6,O,"=
:Output(8,O,"=
:End
:Output(2,12,"TIME
:Output(3,12,"ALIVE
:Repeat D=N
:getKey→C
:N→O
:If M≥1000
:Output(4,12,M
:If M<1000
:Output(4,13,M
:If E=1
:Output(7,12,"DODGE
:N-(C=24)+(C=26→N
:If N=1
:10→N
:If N=11
:2→N
:Output(8,O,"
:Output(8,N,"Ç
:Output(1,L,"
:Output(2,F,"
:Output(3,K,"
:Output(4,J,"
:Output(5,I,"
:Output(6,G,"
:Output(7,H,"
:H→D
:G→H
:I→G
:J→I
:K→J
:F→K
:L→F
:randInt(2,10→L
:Output(1,L,"Ô
:Output(2,F,"Ô
:Output(3,K,"Ô
:Output(4,J,"Ô
:Output(5,I,"Ô
:Output(6,G,"Ô
:Output(7,H,"Ô
:E+(E=1 or E=2→E
:If E=1 or E=2
:Output(7,12,"
:If E=3
:1→E
:M+1→M
:If C=21
:Then
:ClrDraw
:Text(‾1,0,30,"PAUSE
:Text(8,20,"SELECT AN OPTION
:Horizontal(47
:Text(24,29,"CONTINUE
:Text(32,29,"QUIT TO MAIN MENU
:Text(40,29,"SAVE AND CONTINUE
:Text(48,29,"SAVE AND QUIT
:StorePic 1
:20→A
:33→B
:Repeat C=21 or C=105
:1→dim(L3
:1→dim(L4
:augment(L3,L1+A→L3
:augment(L4,L2+B→L4
:Plot1Scatter ,L3,L4,∙
:RecallPic 1
:Repeat C=21 or C=105 or (C=25 and B≠33) or (C=34 and B≠9)
:getKey→C
:End
:B+8(C=25→B
:B-8(C=34→B
:End:ClrDraw:PlotsOff
:If B=25
:D→N
:If B=17
:0,D,E,F,G,H,I,J,K,L,M,N→∟A
:If B=9
:Then
:0,D,E,F,G,H,I,J,K,L,M,N→∟A
:D→N
:End
:End
:End
:0→C
:Output(8,N,"*
:Output(8,N-1,"*
:Output(8,N+1,"*
:Output(7,N,"*
:Output(8,N+2,"*
:Output(7,N+1,"*
:Output(6,N,"*
:Output(7,N-1,"*
:If N>2
:Output(8,N-2,"*
:For(O,1,200
:End
:M→F
:((((2M)+381+(3M))*M))→M
:ClrHome
:Disp "You Scored",M,"points!","","Time Alive=",F
:Pause
:ClrHome
:0→C
:End
:If (C=21 or C=105) and B=17
:Then
:ClrDraw
:Text(‾1,0,10,"INSTRUCTIONS
:Text(27,3,"USE LEFT RIGHT ARROWS TO
:Text(35,36,"MOVE
:Text(43,10,"PRESS 2nd TO PAUSE GAME
:Text(51,12,"PRESS ENTER TO RETURN
:Pause
:0→C
:End
:If (C=21 or C=105) and B=9
:Then
:ClrDraw
:Text(‾1,0,30,"ABOUT
:Text(8,3,"THIS GAME WAS CREATED BY
:Text(16,10,"JOSH FRISBY JGAMES
:Text(24,25,"OPTIMIZED BY
:Text(32,0,"ROBERTO SANCHEZ CEMETECH
:Text(40,15,"SEND QUESTIONS TO
:Text(48,13,"SANCHEZSTIS.NET
:Text(56,10,"PRESS ENTER TO RETURN
:Pause
:0→C
:End
:End
:ClrDraw
:ZStandard
:ClrHome
:Line(‾8,8,8,8
:Line(8,8,8,‾8
:Line(8,‾8,‾8,‾8
:Line(‾8,‾8,‾8,8
:Line(8.3,7.7,8.3,‾8.3
:Line(‾7.7,‾8.3,8.3,‾8.3
:Text(27,10,"THANK YOU FOR PLAYING
:For(A,1,200
:End
:For(A,‾.7,1.1,.3
:Line(‾7.7,A,7.7,A,0
:End
:Text(27,30,"JDODGE
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar IDelVar JDelVar KDelVar LDelVar MDelVar NDelVar ODelVar Pic1DelVar L1DelVar L2DelVar L3DelVar L4ClrDraw
:Output(1,1,"
:AxesOn
:Return
Generated by SourceCoder, © 2005 Cemetech
For this:

Code:
For(X,A,B:End
as a pause loop, use:

Code:
rand((B-A)/4)
where A and B and ((B-A)/4) are numbers.
KermMartian wrote:
For this:

Code:
For(X,A,B:End
as a pause loop, use:

Code:
rand((B-A)/4)
where A and B and ((B-A)/4) are numbers.
Don't you mean:
Code:
(B-A)/4rand
It knocks 2 bytes off Smile
no, I mean rand(2) or rand(30) or rand(50). Smile
Explain please.
A pause loop looks for speed delay. I'd imagine that rand(A is slower than Arand (which is what you want)
Rand(NNN) creates a list with NNN elements. It takes several seconds per 100 elements.
That's not helping...
Look, suppose you have:
Code:
For(X,0,200:End
. You can replace it with
Code:
rand(50
Oh I see. I kept thinking about rand as working like RandInt because I forgot it only created random numbers between 0 and 1. After checking the manual, I saw it repeated the process for specified number of trials. This should be in the 1337 Information Guide.
Pretty nifty, eh? Did you try it oncalc?
Hold on I'll try it now.
K, do that. It's not only smaller but fewer lines than a for( loop delay.
This is a good way to use a pause. I'll start using it from now on.
I see 2 optimizations:

Any instance of 0->variable, replace with Delvar.

:B+8(C=25→B
:B-8(C=34→B

can be combined into:

B-(8(C=34)-8(C=25))->B

Nothing too big, but something. Smile
I know about the Delvar thing. I chose 0->variable because it is a faster method.
Ok. Smile I was just going for size.

Also, you can drop the Return at the end of the program. Once the calc reaches the end of the code and there is nothing left to execute, it will automatically return...
This can be changed:
Code:
:((((2M)+381+(3M))*M))→M

to

Code:
:M(5M+381→M

You can also shade off bytes by not closing your ending parenthasees like:

Code:
:If (C=21 or C=105) and (B=33 or B=25)

can be changed to:

Code:
:If (C=21 or C=105) and (B=33 or B=25
You can even optimize those further; lemme think about that.
tifreak8x wrote:
I see 2 optimizations:

Any instance of 0->variable, replace with Delvar.

:B+8(C=25→B
:B-8(C=34→B

can be combined into:

B-(8(C=34)-8(C=25))->B

Nothing too big, but something. Smile
B-8((C=34)-(C=25->B
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement