Hi there,
I have 3 sprites with 3 separate scripts drawing 3 different shapes: a square, a triangle and a circle. All scripts start with "When green flag clicked". It seems that if I include the clear command in the square script or the circle script, all shapes are drawn correctly in parrallel.
When green flag clicked
clear
point in direction 0
repeat 4
set pen colour
pen down
move 50
turn 90
(code is the same for other shapes excepts for no clear command + angles are different)
If I include the clear command in the triangle script only a 3 sided-square is drawn - one side missing. This seems a little strange.
I'm assuming in this case the first side of the square is drawn and then the clear command is executed.
Could you please explain the execution order or explain this issue I have come across here?
Perhaps I should be using clear at a different point altogether to avoid this issue?
All scripts have the same number of lines of code.
Thanks,
Clare.
Offline
The execution order of parallel scripts is NOT defined.
There are two ways to force a particular order:
1) waits
If you have each script wait 0.1 seconds before starting to draw, then all the initialization action will have happened before any of the drawing.
2) messages
If you have just one green-flag script, and it says
when greenflag clicked
clear
broadcast start_drawing
and each drawing script is
when I receive start_drawing
point in direction 0
...
then the clear will only happen once, before any drawing is done.
I would put the green-flag script on the stage, rather than on specific sprites, since it is coordinating the action of several sprites.
Offline