I am in the process of designing a ti-83+ Dr. Bacon logo. It is almost done, except that I have encountered a strange problem in the last few lines of code. I'm sure it's just a mistake that I have repeatedly overlooked, but I am quite stumped.

So far, the logo thing looks like this:
And I want the squiggly thing on the bottom to be a piece of bacon. The end part of the simple code that I wrote that deals with the strip of bacon goes something like this:


Code:
:-3→X
:0→I
:0→J
:While I≤3
:While J≤5
:Line(5,23-X,17,28-X
:Line(17,28-X,26,29-X
:X+1→X
:J+1→J
:End
:X+5→X
:I+1→I
:End


Just like to not that those are not the only two Line(s there, but there are like twenty all formatted the same way.

Everything has worked well up until this point. There was supposed to be a five line skip, and then the same squiggly 5 pixels lower down. Any ideas?

Thanks,

~Dr. Bacon
Well first, switch to for loops instead of the while's:

Code:
:-3→X
:0→I
:0→J
:For(I,1,3
:For(J,1,5
:Line(5,23-X,17,28-X
:Line(17,28-X,26,29-X
:X+1→X
:End
:X+5→X
:End


Second, what is your window range? Third, what exactly is the code supposed to produce?
Roguebantha wrote:
Well first, switch to for loops instead of the while's:

The problem isn't in his repertoire of control structures, but his logical forte even with an already-sufficient toolbox.

Roguebantha wrote:
Second, what is your window range? Third, what exactly is the code supposed to produce?

0–94 and 0–62, as discerned by executing his code and comparing it to the screenshot. His last paragraph explains what he wants.

With that, DoctorBacon, I'll use just what is known to you so far to reveal how it can be done.

Code:
:0→I
:While I≤1
:-3→X
:If I=1
:7→X
:0→J
:While J≤4
:Line(5,23-X,17,28-X
:Line(17,28-X,26,29-X
:X+1→X
:J+1→J
:End
:I+1→I
:End


Now we'll introduce the For( loops.

Code:
:For(I,0,1
:-3→X
:If I=1
:7→X
:For(J,0,4
:Line(5,23-X,17,28-X
:Line(17,28-X,26,29-X
:X+1→X
:End
:End


From there, notice that it's incrementing X and using it to change the row that it's drawing on, then it's incrementing J and using that as a counter. These two variables serve very similar purposes; in fact, you can do just as well without one of them.

Code:
:For(I,0,1
:-3→J
:If I=1
:7→J
:For(J,J,J+4
:Line(5,23-J,17,28-J
:Line(17,28-J,26,29-J
:End
:End


See if you can get this next part without me describing why it is so. Instead of:

Code:
:-3→J
:If I=1
:7→J


I write:

Code:
:10I-3→J


I think that's good enough for now. Though, I wouldn't call this routine fully optimized yet!
  
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