Tuesday, October 27, 2009

Sugar - Etoys Activity

For the past 2 weeks our control tech class had been working with the activity from sugar, Etoys. Etoys is an activity that allows us to animate pictures that we draw by using scripts. In each script we put in commands, similar to the turtle activity; commands such as forward and turn by a specified number. We could also change the speed in which an object moved either by a set number or random.

Our task was to draw cars and make it move and do this according to each task. All the tasks involved cars or race cars.

One of the tasks was to simulate a car race using many commands from the command window. We had to use variables for the cars speed and make it random and we also had to make a time variable to create a time that started and stopped whenever the race started and ended.

The cars were able to stop using the "Test" command which allowed a car to do certain things whenever a colour on the car touched another colour (both colours are chosen by us). In this racing case the test command made all scripts (time scripts, cars scripts) stop whenever one car won the race.

All cars had to move on their own. This was made possible by using another test. That test would work by if the colour on the car touches the colour of the sides of the lane it would bounce and turn left or right depending on what side it bumps into (If it hit the right side it would bounce left to put it back in place).

We also had to make a timer to time how long the race went for and it would stop when the race ended. It was pretty simple, we just had to make a time variable and make a script telling it to increase its value by 1 each second.

All this is started by a start button which we could create. It was simple to create a start button because the script for the start button only consisted of "start" commands, starting all scripts (time scripts, car scripts).

We also had to make a reset button, similar to start except it would put all cars and time to its original position and value. I used a script type called "World" because that way it was able to start the same scripts if they were under the same script names and I found that this way was easier. To reset the positions of each car we had to go to each of their command boxes ( a window with commands) and take their coordinates X, Y and heading so that when the reset button is pressed the car would return to those coordinates and facing/heading the same direction. The time would have to reset to 0 as well, which was done by putting values of 0 from the timer variable into the script.

This is my script of the great race, racing 4 cars with all random speeds.
My thoughts on Etoys are that it was pretty simple and easy to follow. The only problem was that we could not view the script while the race started because it would have gotten in the way with the test commands and it would just put the cars off course.
The race without the script in the way.