Drawing your own robot.

To draw your own robot, open the robot ‘handles’ : put your cursor over the robot, and ALT-click. Click on the red ‘paint’ cursor to open the drawing tools. Use these tools to draw a robot of your own.

You should draw your robot facing to the right, as the bots are created by the Bot class facing to the right. There are two extra buttons which will zoom or rotate your drawing.

Once you are happy with your robot drawing, click on the ‘Keep’ button in the drawing tool. This closes the painting tool.

To save your drawing so that you can use it again, ALT-click on the robot again to see the ‘handles’, then click on the blue ‘Save Graphics’ handle. A box will open, asking you to give your root a name, then it will save that robot to the same folder as your image file, with the name you gave it and the extension .frm

Now that you have your drawing, you should tell the computer that robots can look like this. Use the command passImageToClass – you can do this in a speech balloon. Once you have done this, then the command lookLikeImage will cause all newly created robots to look like your drawing.

Assignment 13:

Draw your own robot – be creative. Save it as name.image

Assignment 14:

Declare another robot name. Draw a different robot, so that you can call both within the same script. Give it a different name.

Using these commands in a script.

When you loaded this program, it came with three image files – luth.frm, spider.frm and airplane.frm

| pica berthe |

Bot clearImage. "clears any graphic that was previously associated with the class Bot."

berthe := Bot new. "berthe looks like a default robot"

Bot loadImage: 'spider'. "The image in spider.frm is associated with the Bot class"

Bot lookLikeImage

pica := Bot new. "The robot pica looks like a spider"

Bot saveImage: 'spider3' "The spider image is saved under the name spider3.frm"

This script clears the bot image, and put the picture from ‘spider.frm’ in its place.

Read this script carefully. Read the comments in italics, which explain what the script is doing.

Script 6-7. Changing the image of a robot

| pica berthe |

Bot clearImage.

pica := Bot new.

pica lookLikeImage.

" No image loaded or created, so nothing changes, because pica isn’t told what it should look like"

pica loadImage: 'luth'.

pica lookLikeImage

"Now the program has loaded an image ‘luth’ and asks the robot to look like it"

pica loadImage: 'spider'.

"load another image, and since the message lookLikeImage has already been

sent, pica will look like the new image"

berthe := Bot new.

berthe lookLikeImage.

"When berthe is created, she looks like a default robot, and since no image

has been loaded into the class, the message lookLikeImage causes nothing to

change"