So I got bored today and made a program that will do a couple of things while it moves a pixel across the screen, I will edit this with an image from Wabbitemu in a few, but I wanted to figure out a way I could make it so I can display a 2x2,3x3, or more in the future, I thought I remembered reading a way to make one of the Draw commands display larger then 1x1 pixel boxes at one time and not take time to draw them one pixel at a time, as that adds a horribly annoying flashing effect.

BASIC Code wrote:
:ClrDraw:0→K
:ClrHome:0→J
:46→A:31→B
:0→C:0→D
:Pxl-On(B,A
:Repeat K=155
:getKey→K
:If J=1
:Pxl-Off(B,A
:C-(K=24)+(K=26)→C
:D-(K=25)+(K=34)→D
:A+C→A:B+D→B
:If A≤1:Then
:1→A:C‾1→C:End
:If A≥94:Then
:93→A:C‾1→C:End
:If B≤1:Then
:1→B:D‾1→D:End
:If B≥62:Then
:61→B:D‾1→D:End
:Pxl-On(B,A
:Text(0,0,J
:If K=21:ClrDraw
:If K=31:Then
:0→C:0→D:End
:If K=22:Then
:J+(J=0)-(J=1)→J
:End:End
Generated by SourceCoder, © 2005-2010 Cemetech


Also I know it has a ton of room for optimization, I just am making a sort of "rough draft" to get everything working.
You can draw a 3x3 + symbol and a 3x3 box symbol by using, respectively:


Code:
Pt-On(X,Y,2
Pt-On(X,Y,3
KermMartian wrote:
You can draw a 3x3 + symbol and a 3x3 box symbol by using, respectively:


Code:
Pt-On(X,Y,2
Pt-On(X,Y,3


Very nice catch, I missed that entirely.
I don't know if you tested your program to be working, but here's a few assorted optimizations of what you have so far. Notes:

:: No need to initialize K, since you're using a Repeat loop.
:: 0->Var replaced with DelVar for C, D, and J
:: You have C‾1→C twice. If you are negating C, it should be ‾C→C. If you're trying to subtract one, it should be C-1→C
:: Same with D‾1→D
:: J+(J=0)-(J=1)→J optimized to use not(), and extraneous Then/End around it removed.


Code:
:ClrDraw:ClrHome
:46→A:31→BDelVar CDelVar DDelVar J
:Pxl-On(B,A
:Repeat K=155
:getKey→K
:If J=1
:Pxl-Off(B,A
:C-(K=24)+(K=26→C
:D-(K=25)+(K=34→D
:A+C→A:B+D→B
:If A≤1:Then
:1→A:C‾1→C:End
:If A≥94:Then
:93→A:C‾1→C:End
:If B≤1:Then
:1→B:D‾1→D:End
:If B≥62:Then
:61→B:D‾1→D:End
:Pxl-On(B,A
:Text(0,0,J
:If K=21:ClrDraw
:If K=31:Then
:DelVar CDelvar DEnd
:If K=22:J+not(J)-(J=1→J
:End
Sonlen, what you'll probably want is to do is have the calc remember the previous coordinates. You can do this by storing the coordinates into (what I call) "lagged coordinates". What that means is that before it will ever change the coordinates at all, it will store the coordinates into these lagged coordinates. This way, it knows where it just was, and where it is now. By using one lagged coordinate, you can turn off the previous pixel. By using two lagged coordinates, you can make a line between the first two, and delete the line between the second and the last, thereby allowing you to make a line. If you use three lagged coordinates, then you can have two lines, one following the other. In my BOUNCING program, I believe I used 8 lagged coordinates, but I could have easily made it 30. The major problem, though is that for each lagged coordinate, you require two variables. This wasn't a problem for my BOUNCING program, because it was an "Ans program" and could use as many as 999 variables (max dimensions of a list), but many lagged coordinates could prove to be troublesome in a program that already uses many variables. Also, there's an issue with the speed, as the more lagged coordinates, the longer it take to lag each coordinate before displaying the new coordinates. Again, this was little of an issue with my BOUNCING program, because I didn't have to make another two lines of code per lagged coordinate, but only add another 2 elements to the Ans list.
MufinMcFlufin wrote:
Sonlen, what you'll probably want is to do is have the calc remember the previous coordinates. You can do this by storing the coordinates into (what I call) "lagged coordinates". What that means is that before it will ever change the coordinates at all, it will store the coordinates into these lagged coordinates. This way, it knows where it just was, and where it is now. By using one lagged coordinate, you can turn off the previous pixel. By using two lagged coordinates, you can make a line between the first two, and delete the line between the second and the last, thereby allowing you to make a line. If you use three lagged coordinates, then you can have two lines, one following the other. In my BOUNCING program, I believe I used 8 lagged coordinates, but I could have easily made it 30. The major problem, though is that for each lagged coordinate, you require two variables. This wasn't a problem for my BOUNCING program, because it was an "Ans program" and could use as many as 999 variables (max dimensions of a list), but many lagged coordinates could prove to be troublesome in a program that already uses many variables. Also, there's an issue with the speed, as the more lagged coordinates, the longer it take to lag each coordinate before displaying the new coordinates. Again, this was little of an issue with my BOUNCING program, because I didn't have to make another two lines of code per lagged coordinate, but only add another 2 elements to the Ans list.


You could store the X coordinate as the integer part and the Y coordinate as the decimal part:

(5,3) becomes 5.3
Problem with that is that it then has to decrypt, most likely using int( and fPart(, which aren't very fast commands.
  
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