File: getting-started.docbook

package info (click to toggle)
kturtle 4%3A25.04.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,392 kB
  • sloc: cpp: 7,717; ruby: 2,217; xml: 243; makefile: 3; sh: 3
file content (146 lines) | stat: -rw-r--r-- 7,845 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<chapter id="getting-started">
<title>Getting Started</title>
<para>When you start &kturtle; you will see something like this:</para>
<screenshot>
  <screeninfo>Here is a screenshot of &kturtle; when you start it for the first time</screeninfo>
  <mediaobject>
    <imageobject>
      <imagedata fileref="mainwindow.png" format="PNG"/>
    </imageobject>
    <textobject>
      <phrase>&kturtle; on a fresh start</phrase>
    </textobject>
  </mediaobject>
</screenshot>
<para>In this Getting Started guide we assume that the language of the &turtlescript; commands is English. You can change this language with the <menuchoice><guimenu>Settings</guimenu><guisubmenu>Script Language</guisubmenu></menuchoice> submenu. Be aware that the language you set here for &kturtle; is the one you use to type the &turtlescript; commands, not the language used by &kde; on your computer and used to display the &kturtle; interface and menus.</para>

<sect1 id="first-steps">
<title>First steps with &turtlescript;: meet the Turtle!</title>
<para>You must have noticed the turtle in the middle of the canvas: you are just about to learn how to control it using commands in the editor.</para>

<sect2 id="the-turtle-moves">
<title>The Turtle Moves</title>
<para>Let us start by getting the turtle moving. Our turtle can do 3 types of moves, (1) it can move forwards and backwards, (2) it can turn left and right and (3) it can go (jump) directly to a position on the screen. Try this for example:</para>
<para>
<screen>
forward 100
turnleft 90 
</screen>
Type or copy-paste the code to the editor and execute it (using <link linkend="run-execute"><menuchoice><guimenu>Run</guimenu><guimenuitem>Run</guimenuitem></menuchoice></link>) to see the result.</para>

<para>When you typed and executed the commands like above in the editor you might have noticed one or more of the following things:</para>
<orderedlist>
<listitem><para>That &mdash; after executing the commands &mdash; the turtle moves up, draws a line, and then turns a quarter turn to the left. This because you have used the <link linkend="forward"><userinput>forward</userinput></link> and the <link linkend="turnleft"><userinput>turnleft</userinput></link> commands.</para>
</listitem>
<listitem>
<para>That the color of the code changed while you where typing it: this feature is called <emphasis>intuitive highlighting</emphasis> &mdash; different types of commands are highlighted differently. This makes reading large blocks of code more easy.</para>
</listitem>
<listitem>
<para>That the turtle draws a thin black line.</para>
</listitem>
<listitem>
<para>Maybe you got an error message. This could simply mean two things: you could have made a mistake while copying the commands, or you should still set the correct language for the &turtlescript; commands (you can do that by choosing the <menuchoice><guimenu>Settings</guimenu><guisubmenu>Script Language</guisubmenu></menuchoice> submenu).</para>
</listitem>
</orderedlist>

<para>You will likely understand that <userinput>forward 100</userinput> instructed the turtle to move forward leaving a line, and that <userinput>turnleft 90</userinput> instructed the turtle to turn 90 <glossterm linkend="degrees">degrees</glossterm> to the left.</para>

<para>Please see the following links to the reference manual for a complete explanation of the new commands: <link linkend="forward"><userinput>forward</userinput></link>, <link linkend="backward"><userinput>backward</userinput></link>, <link linkend="turnleft"><userinput>turnleft</userinput></link>, and <link linkend="turnright"><userinput>turnright</userinput></link>.</para>
</sect2>

<sect2 id="more-examples">
<title>More examples</title>
<para>The first example was very simple, so let us go on!</para>

<para>

<screen>
reset

canvassize 200,200
canvascolor 0,0,0
pencolor 255,0,0
penwidth 5

go 20,20
direction 135

forward 200
turnleft 135
forward 100
turnleft 135
forward 141
turnleft 135
forward 100
turnleft 45

go 40,100
</screen>
Again you can type or copy-paste the code to the editor or open the <filename>arrow</filename> example in the <guimenu>Examples</guimenu> submenu and execute it (using <link linkend="run-execute"><menuchoice><guimenu>Run</guimenu><guimenuitem>Run</guimenuitem></menuchoice></link>) to see the result. In the next examples you are expected to know the drill.</para>

<para>You might have noticed that this second example uses a lot more code. You have also seen a couple of new commands. Here a short explanation of all the new commands:</para>

<para>After a <userinput>reset</userinput> command everything is like is was when you had just started &kturtle;.</para>

<para><userinput>canvassize 200,200</userinput> sets the canvas width and height to 200 <glossterm linkend="pixels">pixels</glossterm>. The width and the height are equal, so the canvas will be a square.</para>

<para><userinput>canvascolor 0,0,0</userinput> makes the canvas black. <userinput>0,0,0</userinput> is a <glossterm linkend="rgb">RGB-combination</glossterm> where all values are set to <userinput>0</userinput>, which results in black.</para>

<para><userinput>pencolor 255,0,0</userinput> sets the color of the pen to red. <userinput>255,0,0</userinput> is a <glossterm linkend="rgb">RGB-combination</glossterm> where only the red value is set to <userinput>255</userinput> (fully on) while the others (green and blue) are set to <userinput>0</userinput> (fully off). This results in a bright shade of red.</para>

<para>If you do not understand the color values, be sure to read the glossary on <glossterm linkend="rgb">RGB-combination</glossterm>.</para>

<para><userinput>penwidth 5</userinput> sets the width (the size) of the pen to <userinput>5</userinput> <glossterm linkend="pixels">pixels</glossterm>. From now on every line the turtle draw will have a thickness of <userinput>5</userinput>, until we change the <userinput>penwidth</userinput> to something else.</para>

<para><userinput>go 20,20</userinput> commands the turtle to go to a certain place on the canvas. Counted from the upper left corner, this place is 20 <glossterm linkend="pixels">pixels</glossterm> across from the left, and 20 <glossterm linkend="pixels">pixels</glossterm> down from the top of the canvas. Note that using the <userinput>go</userinput> command the turtle will not draw a line.</para>

<para><userinput>direction 135</userinput> set the turtle's direction. The <userinput>turnleft</userinput> and <userinput>turnright</userinput> commands change the turtle's angle starting from its current direction. The <userinput>direction</userinput> command changes the turtle's angle from zero, and thus is not relative to the turtle previous direction.</para>

<para>After the <userinput>direction</userinput> command a lot of <userinput>forward</userinput> and <userinput>turnleft</userinput> commands follow. These command do the actual drawing.</para>

<para>At last another <userinput>go</userinput> command is used to move the turtle aside.</para>

<para>Make sure you follow the links to the reference. The reference explains each command more thoroughly.</para>


</sect2>
</sect1>



<!--        EXTRA SECTIONS CAN BE ADDED TO THE "GETTING STARTED"

<sect1 id="calculations">
<title>Simple Calculations</title>
<para>
Not yet written
</para>
</sect1>
<sect1 id="using_variables">
<title>Using Variables: creating 'number containers'</title>
<para>
Not yet written
</para>
</sect1>
<sect1 id="using_strings">
<title>Using strings: creating 'text containers'</title>
<para>
Not yet written
</para>
</sect1>
<sect1 id="logic">
<title>Logic: asking the computer simple questions</title>
<para>
Not yet written
</para>
</sect1>
<sect1 id="recursion">
<title>Recursion: the Turtle is using itself</title>
<para>
Draw a maze for example
</para>
</sect1>
-->


</chapter>