13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The outer REPEAT first calls MAKETRGL. This procedure, still to bedefined, chooses three random points on a circle of radius 95 and storestheir coordinates in the array TRGL. It also stores the coordinates of thethird corner in the variable CORNER.Next, the function ARBITRARY is used to assign a random value to THETA,the number of degrees to rotate the triangle.The main program is nearly complete. It remains only to add one newvariable named CENTER (of type POINT), and a few initializing statementsbefore the outer REPEAT:VAR CYCLES: fl •• 2;THETA:3 .. 15;TRGL:ARRAYC1 .. 31 OF POINT;c: 1 .. 3;CORNER:POINT;CENTER:POINT;BEGINRANDOMIZE;INITTURTLE;CENTER.X:=TURTLEX;CENTER.V:=TURTLEV;REPEAT(*To get a different seguence each timeprogram is executed*)C*The turtle is at the center because!NITTURTLE leaves it there. Saveits coordinates in CENTER.*)REPEATUNTIL CYCLES=2UNTIL KEVPRESSEND.The main program is complete, and now we must define the two proceduresMAKETRGL and ROTATE and the function ARBITRARY.The ARBITRARY function is a simplified version of the RANDl functiondescribed in "Using the RANDOM Function" in Chapter 6 of Part III.RANDI handles unacceptable parameters by setting a VAR parameter oftype BOOLEAN. ARBITRARY does not need this error-handling capabilitybecause it will always be called with constants as parameters. Similarly,An Annotated Graphics Program 11-301

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!