next up previous
Next: 3 The Traveling Salesman Up: APS105S Monday Quiz 2 Previous: 1 Linked List Manipulation

2 A Graphical Animation

You are to write a Turing program that draws a picture and moves it around the screen, using Turing graphics functions.

The program inputs two files: the first file describes a picture by giving a number of (x,y) points that are the endpoints of lines to be drawn (see below for details of how this is to be done). The second file gives a series of (tex2html_wrap_inline105x, tex2html_wrap_inline105y) pairs. Your program should draw the picture (described by the first file) several times, once for each (tex2html_wrap_inline105x, tex2html_wrap_inline105y) pair in the second file. Each time, the picture should be displaced from its original position (described by the first file) by the amount (tex2html_wrap_inline105x, tex2html_wrap_inline105y). That is, a point that is specified as (x,y) in the first file, should actually be drawn as (tex2html_wrap_inline121, tex2html_wrap_inline123).

The format of the first (picture) file is as follows:

N	
X1 Y1
X2 Y2
X3 Y3
.
.
XN YN
N is the number of (x,y) pairs to input. The picture should be drawn by drawing a line from (X1,Y1) to (X2,Y2), and then from (X2,Y2) to (X3,Y3) and so on. You may choose any visible colour to draw with.

The file that describes the motion, which contains the (tex2html_wrap_inline105x, tex2html_wrap_inline105y) pairs, has this same format.

Your program should prompt the user to input the names of the files to read. Test your program with the files /usr/copy/aps105/pict for a picture file, and /usr/copy/aps105/moves for the motion file. The picture is a square with a cross in it. The motion file should cause the picture to move from your left to the right, twice, once at near the bottom of the window, and once near the top.

The screen should be erased before each time the picture is drawn, using the cls procedure call. Assume that all X,Y pairs are given in Turing screen co-ordinates so that you don't have to translate them (i.e. tex2html_wrap_inline131, and tex2html_wrap_inline133). Also, you don't need to check the input files for correctness.

Restrictions

A solution


next up previous
Next: 3 The Traveling Salesman Up: APS105S Monday Quiz 2 Previous: 1 Linked List Manipulation

Jonathan Rose
Fri Apr 4 13:36:24 EST 1997