Changes

Jump to navigation Jump to search
1,868 bytes added ,  11:15, 10 June 2010
Line 162: Line 162:     
== Modifying Abacus ==
 
== Modifying Abacus ==
We are just trying to check the multiple folks editing the same page
+
Turtle Art is under the MIT license. You are free to use it and learn with it. You are also encourage to modify it to suit your needs or just for a further opportunity to learn.
   −
aljdflksjdf;alkdsjflsdkjflskdlkjdf
+
Much of the motivation behind the Version 0.83 refactoring of the code was to make it easier for you to make changes. Most changes can be confined to two modules: taconstants.py and talogo.py. The former defines the blocks and palettes; the latter defines what code is executed by a block.
 +
 
 +
taconstants.py contains the constants that by-in-large determine the behavior of Turtle Art. Notably, the block palettes are defined below. If you want to add a new block to Turtle Art, it is generally a matter of modifying some tables below and then adding the primitive to talogo.py. For example, if we want to add a new turtle command, 'uturn', we'd make the following changes:
 +
 
 +
(1) We'd add 'uturn' to the PALETTES list of lists:
 +
 
 +
PALETTES = [['forward', 'back', 'clean', 'left', 'right', 'show',
 +
              'seth', 'setxy', 'heading', 'xcor', 'ycor', 'setscale',
 +
              'arc', 'scale', 'left', 'top', 'right', 'bottom', 'uturn'],
 +
            ['penup','pendown', 'setpensize', 'fillscreen', 'pensize',...
 +
 
 +
(2) Then we'd add it to one of the block-style definitions. Since it takes
 +
no arguments, we'd add it here:
 +
 
 +
BASIC_STYLE = ['clean', 'penup', 'pendown', 'stack1', 'stack2', 'vspace',
 +
    'hideblocks', 'showblocks', 'clearheap', 'printheap', 'kbinput', 'uturn']
 +
 
 +
(3) Then we give it a name (Note the syntax _('string to be
 +
translated') used by the language-internationalization system; also
 +
note that the name is an array, as some blocks contain multiple
 +
strings.):
 +
 
 +
BLOCK_NAMES = {
 +
...
 +
    'uturn':[_('u-turn')],
 +
...
 +
              }
 +
 
 +
(4) and a help-menu entry:
 +
 
 +
HELP_STRINGS = {
 +
...
 +
    'uturn':_('change the heading of the turtle 180 degrees'),
 +
...
 +
              }
 +
 
 +
(5) Next, we need to define it as a primitive for the Logo command
 +
parser (generally just the same name):
    
==Discussion==
 
==Discussion==
9

edits

Navigation menu