check this out. i took phil killewalds frogger changed a few things and optimized it and now it is less than 620 memory and runs a lot faster check out the code below.


Code:

:Menu("FROGGER","START",S,"QUIT",Q
:Lbl Q
:ClrHome
:Pause "BYE
:ClrHome
:Output(1,1,"
:Stop
:Lbl S
:ClrHome
:‾1→S
:Lbl 1
:ClrHome
:S+1→S
:8→A
:A→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,"
:Output(1,1,"
:Output(2,1,"
:Output(3,1,"
:Output(4,1,"
:Output(5,1,"
:Output(6,1,"
:Output(7,1,"
: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


and i am sure even that could use more optimizing than what i did.
See if you can't get rid of those last few gotos and labels
Here's some more optimization:

Code:

:Menu("FROGGER","START",S,"QUIT",Q
:Lbl Q
:ClrHome
:Pause "BYE
:ClrHome
:Output(1,1,"
:Return    <--ALWAYS use Return instead of Stop
:Lbl S
:ClrHome
:‾1→S
:Lbl 1
:ClrHome
:S+1→S
:8→A
:8→B     <--- numerical is faster than symbolic if it's the same # of chars
: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   <--- infinite loop: the only way out is a memory leak.  Fix.
: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
While using a list for C from H would slow this down a tiny hair, it would make it much smaller.
@Kerm, lists are much slower than the A-theta vars. The size wouldn't be worth the cost in speed
I know, that's why I made the warning. It would be slower, but if it takes a third of the size off for a slight FPS drop, that's not the end of the world.
Removing the labels, the program is now:

Code:
:"_->Str1
:Repeat Str1="N
:"_->Str1
:1->A
:Repeat max(A={2,3,4,5,6,7} and B={C,D,E,F,G,H
:If A=1
:Then
:ClrHome
:S+1->S
:8->A
:A->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
:End
: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,"
 :Output(1,1,"
 :Output(2,1,"
 :Output(3,1,"
 :Output(4,1,"
 :Output(5,1,"
 :Output(6,1,"
 :Output(7,1,"
 :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
:C+14(not(C->C
:D+14(not(D->D
:E+14(not(E->E
:F+14(not(F->F
:G+14(not(G->G
:H+14(not(H->H
:End
:ClrHome
:Disp "SCORE:",S, "Enter Y To Play","Again or N to","Quit
:Repeat Str1="Y" or Str1="N
:Input ":",Str1
:End
:End
:ClrHome
:Disp "Thanks for
:Pause "Playing!
:ClrHome
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar KDelVar SDelvar Str1Output(1,1,"
OK, here's why I made this.

http://www.cemetech.net/projects/basicelite/sourcecoder2.php?xpi=15a4e1db4c88d91fa60f0bac7f5817df

Just remember to click Save to My Projects when you're done editing.
FROGGER
KermMartian has just edited this program. The source code now reads:
BASIC Code wrote:
:"_->Str1
:Repeat Str1="N
:"_->Str1
:1->A
:Repeat max(A= 2,3,4,5,6,7 and B= C,D,E,F,G,H
:If A=1
:Then
:ClrHome
:S+1->S
:8->A
:A->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
:End
: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,"
:Output(1,1,"
:Output(2,1,"
:Output(3,1,"
:Output(4,1,"
:Output(5,1,"
:Output(6,1,"
:Output(7,1,"
: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
:C+14(not(C->C
:D+14(not(D->D
:E+14(not(E->E
:F+14(not(F->F
:G+14(not(G->G
:H+14(not(H->H
:End
:ClrHome
:Disp "SCORE:",S, "Enter Y To Play","Again or N to","Quit
:Repeat Str1="Y" or Str1="N
:Input ":",Str1
:End
:End
:ClrHome
:Disp "Thanks for
:Pause "Playing!
:ClrHome
:DelVar ADelVar BDelVar CDelVar DDelVar EDelVar FDelVar GDelVar HDelVar KDelVar SDelvar Str1Output(1,1,"
Generated by SourceCoder, © 2005 Cemetech
This is an automatic post from SourceCoder 2. Report abuse to admin@cemetech.net . You can disable these posts by unchecking the "Post on Update" box in the file's permissions.
KermMartian wrote:
I know, that's why I made the warning. It would be slower, but if it takes a third of the size off for a slight FPS drop, that's not the end of the world.


No, I mean it is a signifant speed difference. As in vary large. As in way more than a slight FPS drop.
Fine then, it will have to stay as it is.
  
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 1
» 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