I have been playing around with text sprites today and made 3 of them. I was wondering whether I should use two loops or just one, it is a little smaller with two loops but it is slower since it has an extra condition every time it loops around... Here are two of my sprites, the first one made using only one loop and the second one using two loops (By one and two loops I mean at a time, you will notice there are two For( loops one inside the other in the second method)

Code:
For(A,1,17
Text(1,A,sub(" .Jplotsquareplotsquareu((uuuplotsquareeplotcross.  ",A,1
End
StorePic 1
For(A,1,19
Text(6,A,sub("u[[[[[uu[QYY  ?u   ",A,1
End
RecallPic 1
StorePic 1
For(A,1,18
Text(11,A,sub("YQ[[]   ee  .JeY  ",A,1
End
RecallPic 1
StorePic 1
For(A,1,15
Text(16,A,sub("   ??YY^^^^??  ",A,1
End
RecallPic 1
StorePic 1
For(A,1,23
Text(22,A,sub(" .plotcross+^^^^^^^^^^^^^^^+plotcross. ",A,1
End
RecallPic 1
StorePic 1
For(A,1,24
Text(27,A,sub(" [   QQûQ     QQûQ   [  ",A,1
End
RecallPic 1
StorePic 1
For(A,1,23
Text(32,A,sub(" [   ?^++++++++^?    [ ",A,1
End
RecallPic 1
StorePic 1
For(A,1,23
Text(37,A,sub("  ?^^^^^^^^^^^^^^^^^?  ",A,1
End
RecallPic 1
                                          //END OF FIRST SPRITE\\
For(B,0,5
For(A,1,31
31B+A
Text(12+5B,A+30,sub("     J+^]^^22221+J+12ûplotsquareplotsquare21plotsquare           Q.VQu[[[[QQ.VQu[X[[Q        .e^? ??^^^?....??^^?? Y+J    J^^o?       .eY    ?^^oJ       VJ  [        ^^o^^2..    ..^^2^^o       [   ?^+++plotcrossplotcrossplotcrossplotcrossplotcrossplotcrossplotcross^^2^^2^^2^^2plotcrossplotcrossplotcrossplotcrossplotcrossplotcross+++^?   ",Ans,1
If Ans=31B+31:Then
RecallPic 1
StorePic 1
End:End:End
Pxl-On(13,51
Pxl-On(13,52
DelVar Pic1
Pause
Do this instead:

Code:
For(B,0,5
For(A,1,31
Text(12+5B,A+30,sub("     J+^]^^22221+J+12ûplotsquareplotsquare21plotsquare           Q.VQu[[[[QQ.VQu[X[[Q        .e^? ??^^^?....??^^?? Y+J    J^^o?       .eY    ?^^oJ       VJ  [        ^^o^^2..    ..^^2^^o       [   ?^+++plotcrossplotcrossplotcrossplotcrossplotcrossplotcrossplotcross^^2^^2^^2^^2plotcrossplotcrossplotcrossplotcrossplotcrossplotcross+++^?   ",31B+A,1
End
RecallPic 1
StorePic 1
End
Pxl-On(13,51
Pxl-On(13,52
DelVar Pic1
Pause


It's almost as slow (sub( runs in O(second arg) due to two-byte-token detection, so that's your bottleneck), but it should help a little. There is often a tradeoff between size and speed, so use your judgment. If you want more speed, use the sequence variable n in the inner loop for an additional speedup of 1.6 ms per iteration, or about 300 ms total.
  
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