before reading this, make sure you understand getkey routines and that a line command with ,0 at the end means to turn off the pixels on the line, and works in programming.

Boolean values and tests are a great way to speed up and shorten programs. A good example is for getkey routines.

While 1

getkey->G

If G

Pt-off(A,B

If G=24

A-1->A

If G=26

A+1->A

If G=25

B+1->B

If G=34

B-1->B

If A=-1

A+1->A

If A=95

A-1->A

If B=-1

B+1->B

If B=63

B-1->B

Pt-on(A,B

End

can be much simpler.

While 1

getkey->G

If G

Pt-off(A,B

A+(G=26)-(G=24

Ans+(Ans=-1)-(Ans=95->A

B+(G=25)-(G=34

Ans+(Ans=-1)-(Ans=63->B

Pt-on(A,B

End

the resulting program is 32 bytes smaller, and a lot faster. And all that you have to do is substitute some if tests with math. This works because when you ask a calculator if B=1, it returns 0 if B=1 is false, and 1 if B=1 is true.

Another way that Boolean tests and values can be applied is through drawing of sprites. First, every command in this style must be a line command, which is the only drawback. If you are drawing a moving guy, here is a good example on what to change.

Instead of

If G

Then

Line(A,B,A-3,A-5,0

Line(A,B,A+3,A-5,0

Line(A,B,A,B+3,0

Line(A-3,B+3,A+3,B+3,0

Line(A-1,B+3,A-1,B+5,0

Line(A+1,B+3,A+1,B+5,0

Line(A+1,B+5,A-1,B+5,0

End

Line(A,B,A-3,A-5

Line(A,B,A+3,A-5

Line(A,B,A,B+3

Line(A-3,B+3,A+3,B+3

Line(A-1,B+3,A-1,B+5

Line(A+1,B+3,A+1,B+5

Line(A+1,B+5,A-1,B+5

You can put

Line(A,B,A-3,A-5,not(G

Line(A,B,A+3,A-5,not(G

Line(A,B,A,B+3,not(G

Line(A-3,B+3,A+3,B+3,not(G

Line(A-1,B+3,A-1,B+5,not(G

Line(A+1,B+3,A+1,B+5,not(G

Line(A+1,B+5,A-1,B+5,not(G

this works because when G is 0, it is flipped to 1 with not, and the lines are drawn. then when a key is pressed, G becomes a number other than 0, and not flips it to 0. this causes the lines to be erased. Then you put your boolean tests after the commands, which move the position of the guy by 1 pixel. Then, after the getkey is encountered again, G is set back to 0, and the process repeats itself.

the final program for moving a guy 1 pixel at a time looks like this.

47->A

31->B

While 1

getkey->G

Line(A,B,A-3,A-5,not(G

Line(A,B,A+3,A-5,not(G

Line(A,B,A,B+3,not(G

Line(A-3,B+3,A+3,B+3,not(G

Line(A-1,B+3,A-1,B+5,not(G

Line(A+1,B+3,A+1,B+5,not(G

Line(A+1,B+5,A-1,B+5,not(G

A+(G=26)-(G=24

Ans+(Ans=-1)-(Ans=95->A

B+(G=25)-(G=34

Ans+(Ans=-1)-(Ans=63->B

End