TI-BASIC:Random Lines

From Learn @ Cemetech
Revision as of 18:20, 24 February 2016 by Maintenance script (talk | contribs) (Initial automated import)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

File:@@

Routine Summary

Displays random lines.

Inputs

None

Outputs

None

Variables Used

A, B, C

Calculator Compatibility

TI-83/84/+/SE Author

@@Authors

@@URL: [@@] Download

file randomlines.zip

:ClrDraw
:ZStandard
:Delvar ADelvar B
:Repeat getKey
:randInt(Xmin,Xmax→C
:randInt(Ymin,Ymax
:Line(A,B,C,Ans
:Ans→B:C→A
:End

Before we can start displaying random lines on the graph screen, we need to perform some basic Setup. We then create two variables for the first (X,Y) coordinate by setting their initial values to zero. Once inside the Repeat loop, we randomly select the second (X,Y) coordinate for the line. (Please note we didn't need to store the second variable, since Ans is able to hold a numeric value, and it is also faster.)

Now that we have the two coordinates for the line figured out, we draw the line on the screen and store the first coordinate values to the second coordinate values, i.e., the second coordinate becomes the new first coordinate. This gets repeated over and over again until you press a key.