Значок ресурса

Tortoise II

Нет прав на скачивание
Автор: Chris Davison
Год: 1983
Издатели: Your Computer
Языки: 🇬🇧 Английский
Формат: 📼 TZX лента
Требования: 🖥️ ZX Spectrum 16K

Ссылки:
Страница на ZXArt
Страница на World Of Spectrum
Страница на Spectrum Computing

Скриншоты:
TortoiseII.gif


Tortoise II





Chris Davison coaxes the Spectrum's'


graphics out of their shells with


an ingenious Basic-Logo mix.





One of the most outstanding features of the ZX Spectrum is


its graphics capability. Unfortunately Basic was never


designed to handle graphics and, as a result of this, it is


not easy to produce complex graphic displays.


Logo, on the other hand, was designed to handle graph-


ics, and does so very well, but it is little more than a


graphics language. So imagine the graphics capability of


Logo combined with the mathematical and control capabili-


ties of Basic, combine them into one language and you have


Tortoise.


The idea behind turtle graphics is simple: basically, as


readers of the BBC-orientated articles in Your Computer


January 1983 will know, you are in control of a turtle.


You can instruct the turtle's movements along some sur-


face - for example, the screen, and hence create shapes.


For examine, telling the turtle to:


Move forward one unit


Turn 90º to the left


Move forward one unit


Turn 90º to the left


Move forward one unit


Turn 90º to the left


Move forward one unit


would draw a square. The actual commands of the language


are given later on. Obviously here we can say


Move forward one unit


Turn 90º to the left


four times, or by using the Basic construct


FOR-NEXT


we can say:


FOR count=1 TO 4


(Forward one unit


turn 90º to the left)


NEXT count


Having looked at turtle graphics, let us now look at


Tortoise itself.


The format which Tortoise commands take is as follows.


An instruction is made up of a letter followed by some


parameters separated by commas. A program is made up by a


number of instructions followed by an * and all separated


by colons.


So the instruction to move forward five units is:


f5


/ \


Letter Parameter


and to move to square 50,50 we have


m50,50


/ / | \


Letter /Comma\


Parameter Parameter


Combine the these into a Program and we have


f5:m50,50:*


/-|---+--\ \


Ins1 | Ins2 \ *


Colon Colon


A parameter may be any of the following: a constant, a


variable, an expression. Now that you know a little about


the language, let us look at the program itself.


The routine at 200-330 is designed to let you play turtle


before you combine Tortoise with Basic. You are limited to


just one loop, yet you can produce some very exciting


results. After the prompt


Instruction>


type in your program, for example, try:


fa:r90:*


followed by Enter. The code is then displayed at the top of


the screen and the prompt:


Loop a start>


is given. This asks you at what value you would like the


loop a to start from. Try


2


Then you are asked where you wish the count to finish, try


50


Finally you are asked in what steps you wish the count to


be incremented: try


1


The screen clears and your program is executed. If you


tried the example given, then you should see a square


spiral being drawn.


When it finishes, the prompt


Instruction>


appears again and you can try something else. Note that


this time your drawing will start from the last point plot-


ted, that is, at the end of the spiral, so you may with to


move back to the centre. To do this you can use the Move


command:


m128,88:*


This time type in 1 for all three loop questions; you will


then be ready for your next program. The whole emphasis of


this type of program is on experimentation, so do not be


frightened to have a bash at something new.





Once you have used the package a few times you may wish


to progress. If you delete 200-330, or type


180 GO TO 400


and start your program at 400, you can now type in your own


program. Your computer will only accept Basic, so we must


fool it into thinking that Tortoise is Basic. This is done


by placing your Tortoise code into the string s$ and then


GO SUB tort


to access the main program. So your spiral program now


looks like this:


400 LET s$="fa:r90:*"


410 FOR a=2 TO 50 STEP 1


420 GO SUB tort


430 NEXT a


440 STOP


Do not forget to start your program with


GO SUB 9200


This sets up all the variables used.


When writing your Basic program, be careful not to use


the variables used by the package - see variable list. You


may use them if you wish but remember the package has its


own use for them, so exercise extreme caution. Try this


program:


LET s$="m0,0:ba,20,b:*" [sic - this doesn't work]


FOR a=0 TO 2*PI STEP 0.1


LET b=COS(a)*80+80


GO SUB tort


NEXT a


STOP


The designs are only limited by your imagination.





Now for descriptions of each routine. First the b for Box


routine. For example:


b3,5


This draws a box between the last plotted point and your


two parameters, 3 and 5 in the above example. The c for


Circle:


c7


This draws a circle, whose radius is given as the parameter


and whose centre is the last plotted point.


The e for Edge routine, for example:


e6


This changes the colour of the border to that given by the


parameter, that is e6 changes it to yellow. The f for For-


ward routine, for example:


f7


This moves the turtle forward a distance given by the para-


meter, so here the turtle would move seven spaces forward.


The i for Ink routine, for example:


i4


This changes the colour of the trail left by the turtle,


that is, i4 changes it to green. All colours are as normal


on the Spectrum. The m for Move routine, for example:


m0,0


This moves the last plotted position to the specified co-


ordinate, in this example, the bottom left-hand corner.


The p for Polygon routine, for example:


p5,40,10


This draws a polygon, whose number of sides is given by the


first parameter. The first side of that polygon is a line


between the last plotted position and the last two para-


meters. In this example the polygon is a pentagon.


The r for Rotate routine, for example:


r90


This changes the routine in which the turtle is heading.


Note that the parameter specifies degrees, so here the


turtle turns at a right angle to its old direction.


The s for Screen routine, for example:


s6,0


This changes both the ink and the paper colours, but leaves


the actual picture untouched. The first parameter is ink,


and the second one paper. So in this example we have yellow


ink on black paper.


All that information may be summarised into table 1. All


X,Y co-ordinates are absolute, also colours are as normal


on a Spectrum, for example: 0 is black, 7 is white and so


on.





Now you have seen how to use the program, let us look at


the program itself.


Here is a list of the routines used:


200 Interaction. This allows the user to use turtle


graphics without using Basic.


6000 Decode. This takes each instruction from s$ and breaks


it doesn into separate parameters. These are then


stored in v(), v(1) holds the number of parameters,


the first parameter being held in v(2).


7500 Box 7900 Forward 8200 Polygon


7600 Edge 8000 Ink 8300 Rotate


7570 Circle 8100 Move 8400 Screen


9000 Tortoise. This breaks the program into instructions,


and then uses Decode to obtain parameters. It then


calls the relevant routine.


9200 Initialisation. This sets up all the variables to


their starting values.


Here is a list of all the variables used:


v() Holds all the parameters of current instruction


s$ Holds the Tortoise program


tort Address of Tortoise routine (9000)


x,y Last plotted position


xi,yi x and y increment, altered by Rotate


oldxi,oldyi


rad,oldrad Direction in radians


length Length of side of polygon


angle Angle between sides of polygon


i,a Loop counts


x1,x2,x3 From, to, step in For-Next loop


pt Pointer for s$


vi Index for v()


l$ Segment of s$


c$ Command letter





Here are some programs to be run in the interaction


routine. The three numbers above each line represent the


start, end and step for each loop.


(1) 1,72,1


"m128,88:f72:r-5:*"


(2) 1,109,1


"m200-a:f55:r-5:*"


(3) 1,43,1


"fa*2:r90:ca:*"


(4) 3,100,1


"fa:r70:*"


(5) 3,76,1


"fa*2:r123:*"


(6) 1,201,1


"fa:r177:*"


(7) 3,11,1


"m100,0:pa,150,0:*"


(8) 1,112,1


"fa:c4:r80:*"


Note that you will have to re-centre the last plotted


position each time you run one of the above.





Table 1.| | Para- | Para- | Para-


Name |Letter| meter 1| meter 2| meter 3


--------+------+--------+--------+--------


Box | b |X co-ord|Y co-ord|


Circle | c | Radius | |


Edge | e | Colour | |


Forward | f |Distance| |


Ink | i | Colour | |


Move | m |X co-ord|Y co-ord|


Polygon | p | No. of |X co-ord|Y co-ord


| | sides | |


Rotate | r |Degrees | |


Screen | s | Ink | Paper |
Автор
Verter_bot
Загрузки
0
Просмотры
5
Расширение
zip
Размер
1.6 КБ
Хэш
a7b0f8ff5dfe4fa4471516f701a6721e
Первый выпуск
Последнее обновление

Оценки

0.00 звезд(ы) 0 оценок
Назад
Вверх