These tutorials are also available as a pdf file.
You can also refer to the NodeBox tutorial for more help and instruction on using Spryte.
+
+
+
+
+
+
+
Comments are used for a number of different purposes, but you are likely to find them most handy for writing notes for yourself about your code. Comments are preceded by a "#" character (shift+3 keystroke combination) and remain ignored when the code is executed.
In the following example, a comment has been used to remind the coder what the
rect()
command does. You will also notice that comments are
automatically coloured grey:
# this command makes the background white:
background(1)
In the above example only one comment is used, but you may use as many as you like:
# this command makes the background white:
background(1)
# this command changes the fill colour to red:
fill(1, 0, 0)
# this command renders a rectangle:
rect(10, 10, 50, 60)
Comments can also be used to have Spryte commands ignored; this can be useful
for a number of reasons. In the following example, the oval()
command is ignored meaning that it will not be rendered (although it can always
be made visible by removing the # character preceding it):
# this command makes the background white:
background(1)
# this command changes the fill colour to red:
fill(1, 0, 0)
# this command renders a rectangle:
rect(10, 10, 50, 60)
# this oval command is ignored:
#oval(100, 100, 50, 60)
Another thing to note about comment behaviour is that only the code placed after the # character is ignored. This means that you can still have interpreted code on the same line as your comment -- provided that it is placed in-front of the #, of course:
background(1) # this command makes the background white
fill(1, 0, 0) # this command changes the fill colour to red
rect(10, 10, 50, 60) # this command renders a rectangle
# this oval command is ignored: oval(100, 100, 50, 60)
As the name suggests, multi-line comments span multiple lines. This is handy
for more lengthy descriptions and larger sections of ignored code. To make use
of a multi-line comment, you must place either a triple-single-quote
('''
) or a triple-double-quote ("""
)
at the beginning and end of the code you wish to have ignored.
The following example will render just an oval on a white background. The
commented code (green) is ignored, while the oval()
command on the
last line remains interpreted:
background(1)
fill(1, 0, 0)
'''
all of this code is ignored:
rect(10, 10, 50, 60)
oval(100, 100, 50, 60)
'''
oval(150, 150, 50, 60)
* You should note that if you 'open' your multi-line comment with a triple-single-quote, you must also 'close' it with a triple-single-quote. The same applies for triple-double-quote variant.