You are on page 1of 51

Tutorial for Cocoa:

Cocoa Basics Tutorial


Welcome to the Cocoa Basics Tutorial. We'll create a simple world you can play, enhance, and even
share with your friends on the Web!

You need to have downloaded and installed Cocoa before taking this tutorial.

Table of Contents

Introduction Puzzle to try

Create a Piece Go to the Beyond the Basics section

Write a "Move Right" Rule Get help with the tutorial setup

Write "Jump" Rules Download all the movies in the tutorial


(430K--You can open them with MoviePlayer)
Example world

(Note that the hyperlinks indicated on these pages do not work,


but they would work on the online version of this Tutorial)

Copyright © 1997 Apple Computer, Inc.


Apple, the Apple logo, and Cocoa are trademarks of Apple Computer, Inc. registered in the United States and other
countries.

Maintained by the Apple Cocoa DR Team. Last updated Fri, June 20 1997.
E-mail cocoa@apple.com with problems or questions.
basicforPDF.html Page 1

Welcome to the Basics Tutorial for Cocoa!


The Basics section will help new users learn the basics to building worlds in Cocoa.

Please open your copy of Cocoa and follow along with the steps described in the tutorial.

Some words on these pages are linked to the Tutorial Word List: click on a word if you'd like to see a
definition of it. Click on the BACK button in your browser to return to the Tutorial.

ABOUT COCOA

In Cocoa, only pieces on the board can act in a world. You show your pieces how to act by writing
rules of behavior. All pieces which have rules and are on the board get a chance to try their rules on
every clock tick.

There are 2 steps to getting started:


1. Create a piece and its appearance.

2. Write a rule that makes the piece do something.

This tutorial will show you how to build an obstacle course for a piece to move around.

You'll make a piece and give it a rule that moves it to the right. You'll then give it rules for jumping
on and off of obstacles that get in its way.

And, if you want to see what else your piece can do, you can build a world with more obstacles in it
and give your piece more ways to get through it.

You can download the "Starter World" to your computer. It's about 8K and will take less than a
minute to download.

When you open Cocoa, click the "Open Saved World" button.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 2

Then open the "Starter World" to follow along with this tutorial.

TO CREATE A NEW PIECE

In Cocoa, you start by creating a piece and giving it an appearance. Try not to spend too much time
drawing. You can use a picture that has been drawn in another program or one from the Scrapbook.

1. Click on the.. .. create tool

The cursor turns into the create tool.

Click anywhere above the ground pieces to create new piece on the board.

A new piece looks like a splat of paint.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 3

What a piece looks like is called its appearance. You can change a piece's appearance with the paint
tool.

2. Click on the.. .. paint tool

The cursor turns into the paint tool.

Click on the piece with the paint tool.

This opens the Appearance Editor where you can draw an appearance.

3. Click on .. ..to clear this appearance out of the Appearance Editor.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 4

You can draw any appearance you like, or paste in any picture copied from another program into the
Appearance editor. Use an appearance that takes up only one square on the Cocoa grid.

4. Use the painting tools to draw the appearance or paste one in that you copied from

another program.

You're done with the appearance. Click the.. ..appearance done button.

TO WRITE A "MOVE RIGHT" RULE

The second step is to write a rule that shows your piece what to do. You want your pieces to act a
certain way when they are in a certain situation. To get through the obstacle course, the first thing
your piece has to know how to do is move to the right. You show it how to do that by writing a rule.

Here, we want to set up this situation: If there's an empty space to the right of your piece, it will
move right.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 5

1. Click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

This opens the Rule editor. It shows the before and after sides of a rule.

The board is dark and you can see the grid in the background. A spotlight lights up the area around
your piece.

Before you do anything, the before and after sides in the Rule Editor are the same as what's in the
spotlight on the board.

When you're writing a rule and you do something with your piece, those actions get recorded as a
rule. You can show your piece what to do either in the spotlight on the board or the after side of
the Rule Editor.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 6

Before a rule will work, the left side of the Rule Editor must match what's on the board. It's called
the BEFORE SIDE of the rule. When a rule works, the actions that were recorded when you wrote
the rule get done. Those recorded actions are shown on the right side of the Rule Editor. It's called
the AFTER SIDE of the rule.

In this rule, the piece moves to the right if the space is empty. The action is shown both on the board
and on the after side of the Rule Editor. Notice that the spotlight shows only 2 spaces. That's all your
piece needs to know: as long as there's 1 empty space next to it, it will keep on moving right.

Here's how to write this "Move Right" rule.

2. Drag the spotlight handles to include ONE empty space to the right.

This shows your piece the area you're interested in. It only sees what's in the spotlight and will
ignore everything outside the spotlight.

To show that you want your piece to move to the right, move it into the space to the right. Put the
mouse over the piece, click down on the mouse button and drag.

3. Drag your piece into the empty space to the right.

You have now written a rule that says:

If the space to the right of me is empty . . . then move into it.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 7

You're done with this rule. Click the.. ..rule done button.

You can now see the rule run. Press on.. ..to run the clock and..

..to stop the clock.

Your piece will keep moving right as long as nothing gets in its way. Now you can put
in some obstacles for your piece to jump around.

TO BUILD AN OBSTACLE COURSE

To build a world, you break up the actions into small steps and you write rules for the pieces to
perform the small steps. In the obstacle course world, you create obstacles and you write rules that
will tell your piece to jump ON and OFF an obstacle. It takes 2 small jumps rather than one big leap
over an obstacle.

LOOK BEFORE YOU LEAP! Your pieces only know what you tell them to do. You want your
pieces to act a certain way when they are in a certain situation.

Sometimes you have to try one way before you realize you might want your pieces to act differently.
Don't be afraid to write a rule and see what it does. If you don't like it you can delete it and write a
new rule.

After you write rules that tell your piece when to jump, you can set up an obstacle course for your
piece to jump around.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 8

But first, you need to make a second piece to be the obstacles in this world.

TO MAKE A SECOND PIECE: THE OBSTACLE

1. Click on the.. ..create tool.

The cursor turns into the create tool.

Click to the right of your piece to create a new piece on the board.

A new piece looks like a splat of paint.

What a piece looks like is called its appearance. You can change a piece's appearance with the paint
tool.

2. Click on the.. .. paint tool.

The cursor turns into the paint tool.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 9

Click on the new piece with the paint tool.

This opens the Appearance Editor where you can draw an appearance.

3. Use the painting tools to draw the appearance or paste one in that you copied from

another program.

You're done with the appearance. Click the.. ..appearance Done button.

Your piece knows how to move right, but put an obstacle in its way and it can't move anymore. Start
the clock to see. Stop the clock when your piece gets stuck next to the obstacle.

Here, we want to set up this situation: if there's a block to the right of your piece and the space above
is empty, then your piece will JUMP ON the block. This is the first step to getting around obstacles.

For this rule, move the block to the right side of your piece and make certain the space above it is
empty.

TO WRITE A "JUMP ON" RULE

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 10

1. Set up the board, then click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

This opens the Rule Editor where you record a rule.

2. Drag the spotlight handles to include the block in the space to the right and the empty

spaces above your piece and the block.

3. Then drag your piece on top of the block.

The board has a grid pattern and you can only move pieces into spaces marked by the squares of the
grid.

You have now written a rule that says:

If there's a block to the right of me and the space above is empty . . . then jump on
the block.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 11

You're done with this rule. Click the.. ..rule done button.

Remember, you break up the actions into small steps. The next step is to write a rule that will get
your piece down off of the block.

TO WRITE A "JUMP DOWN" RULE

Now you will write a rule for you piece to jump down. Here's the situation: if your piece is on top of
a block and the space to the right of the block is empty, then your piece will jump down off of the
block into that space.

For this rule, your piece is already in the position you want, so you can go ahead and write the rule.

1. The board is already set. Click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

This opens the Rule Editor where you record a rule.

2. Drag the spotlight handles to include the block below your piece and the empty space

to the right.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 12

3. Then move your piece down off of the block.

You have now written a rule that says:

If I'm on top of a block and the space to the right of the block is empty . . . then
jump down off of the block.

You're done with this rule. Click the.. ..rule done button.

You can now see the rule run. Press on.. ..to run the clock and..

..to stop the clock.

Your piece will move right until it reaches the block. It will jump on and off the block and then
continue to move right.

Now you can put more blocks on the board and see if your piece can make it through the obstacle
course you build.

Also, you can name the pieces to avoid confusion later.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 13

1. Go to the PIECE menu and select "Show Types."

2. Name the Block and your piece in Types window.

3. Drag more blocks from Types window to the board.

Anytime you want to name your types of pieces or get more pieces of any type, go to the PIECE
menu and select "Show Types."

TRY THIS ON YOUR OWN!

In this world, your piece can move around in different ways. Set up the board like the example
shown here to see how your piece can use these 3 rules - move right, jump on and jump down - to
move through these different obstacles.

It can jump over and off a pile of blocks


It can jump over and off a row of blocks

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 14

Try some of your own experiments by moving or adding more blocks.

What's the largest number of obstacles your piece can move around without going off the right side
of the screen?

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

GET A COPY OF THIS WORLD

You can download the "Obstacle Course" world to your computer. It's about 15K and will
take less than 1 minute to download with a 14.4 speed modem.

It has the rules already written for the Cocoa mascot. You can open it and start the clock to see the the

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 15
Cocoa mascot run through this obstacle course.

TRY THESE PUZZLES

Add new obstacles and rules to your piece to make it run through a different obstacle course:

Here are some rules you can try...

Go down under a new piece, for instance, a circle.


Go up around the new piece.

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

Mon, Jun 23, 1997 12:10 PM


basicforPDF.html Page 16

GET A COPY OF THIS WORLD

You can download the "More Obstacles" world to your computer. It's 20K and will take
about 1 minute to download with a 14.4 speed modem.

You'll see that by adding some rules your piece can get around almost any obstacle you build with the
blocks.

Try some of your own experiments by adding different obstacles and giving rules for your piece to
do more.

Mon, Jun 23, 1997 12:10 PM


beyondforPDF.html Page 1

Beyond the Basics


Your piece can do many different things. Choose one of the following to see how to write a rule to do
it.

After you've seen one, you can come back and choose a different one.

Change my appearance - "Turning Around"

Delete another piece - "Eating Food"

Move another piece - "Moving Obstacles"

Create another piece - "Creating Obstacles"

Say a Sound - "Making Sound"

Use Rule Sets - "Group Rules Together"

If you'd rather skip the tutorial, you can get these worlds now. See below.

GET A COPY OF THESE WORLDS

You can download the "Beyond Basics" worlds to your computer. It's 95K and will take
about 2 minutes to download with a 14.4 speed modem. You will get a folder with all the worlds
ready for you to see.

Each world has the rules already written for the Cocoa mascot. You can open one and start the clock
to see the mascot run through the obstacle course.

Start a new world by copying the "Obstacle Course" world done in the "Basics" section. If you
skipped that section, download the "Obstacle Course" world and start with it to go on with
this section.

To avoid confusion, rename the new world "Turning Around" before opening it.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 2

CHANGE MY APPEARANCE

Your piece already knows how to move right when it has a certain appearance and when its in a
certain situation. Appearances are important. If the appearance changes, the situation changes and
your piece will need new rules for the new situation.

In this world, you will write a rule for your piece to turn around if there are 2 blocks in its way.
This will give your piece more ways to get around the obstacle course.

First, you'll need to make a second appearance that your piece will have when it's moving left.
Then you'll write the rule that tells your piece when to change its appearance.

CREATE A SECOND APPEARANCE

1. Select your piece on the board (it looks dark), go to the APPEARANCE menu and

select "Show Appearances."

This opens the Appearances window. Any time you want to see all the appearances a piece has, just
go to the APPEARANCE menu and select "Show Appearances."

2. Go to the APPEARANCE menu and select "New Appearance."

This opens the Appearance Editor for your piece with a COPY of the first appearance it had. You can
change this new appearance so that your piece faces to the left.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 3

In this example, the appearance will be flipped so that the Cocoa mascot is facing left.

3. Go to the PAINT menu and select "Flip Left-Right."

Now, the Cocoa mascot is facing left.

You're done with the appearance. Click the.. ..appearance done button.

Your piece has 2 appearances: appearance 1 faces right and appearance 2 faces left.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 4

Now that your piece has 2 appearances, you can write the rule that will change your piece's
appearance.

TO WRITE "TURN AROUND" RULE

You want your pieces to act a certain way when they are in a certain situation. Appearances are
important. Your piece has rules for when its appearance is facing right, but we want to change that. If
the appearance changes, the situation changes and your piece will need new rules for the new
situation.

Here, we want to set up this situation: if your piece is moving to the right, but there are 2 blocks in its
way, it turns around to the left.

For this rule, put 2 blocks, one above the other, in the space to the right of your piece. Your piece
should still be facing right. (If your piece is facing left, go to the APPEARANCE menu and select
"appearance 1" at the bottom of the menu.)

1. Set up the board, then click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

This opens the Rule Editor where you write the rule.

2. Drag the spotlight handles to include the 2 blocks to the right.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 5

Now you show that you want the appearance to change.

3. Drag appearance 2 (facing left) onto the piece. It has to go on the AFTER side of the

Rule Editor.

This says that you want to change the appearance from facing right to facing left.

You have now written a rule that says:

If I'm moving right and there are 2 blocks, one above the other, to the right of me .
. . then I'll turn to the left.

You're done with this rule. Click the.. ..rule done button.

AN IMPORTANT NOTE ABOUT APPEARANCES

If you dragged the Cocoa mascot's "appearance 2" onto the Block in the rule, the Block wouldn't
change its appearance to look like the Cocoa mascot. When you're changing appearances, be careful
to check who's Appearances you're using and which piece you're dragging that appearance onto.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 6

TRY THIS ON YOUR OWN!

Now that your piece has turned to the left, it doesn't know what to do next. If you run the world, it
will not move. Appearance is important, so now you need to tell it what to do next.

The easiest thing to do is give it a rule that tells it to move left when its facing left. If you need help,
go back to the Move Right section to see how that rule was done, but, this time, write a rule to
move the piece left.

The next thing your piece might do is jump on then off the block when it's moving left. If you need
help, go back to the Jump section, to see how that was done.

Here are some rules you can try...

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 7

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

GET A COPY OF THIS WORLD

You can download the "Turning Around" world to your computer to see what the finished
world looks like. It's about 28K and will take about 1 minute to download with a 14.4 speed modem.

This world has the rules already written for the Cocoa mascot. You can open it and run the world.

Start a new world by copying the "Obstacle Course" world done in the "Basics" section. If you
skipped that section, download the "Obstacle Course" world and start with it to go on with
this section.

To avoid confusion, rename the new world "Eating Food" before opening it.

DELETE OTHER PIECE IN A RULE

Your piece already knows how to move right and jump over a block. That takes a lot of energy!

In this new world, your piece will delete the other piece: this is the kind of rule you write when you
want one piece to "eat" the other piece to get energy.

First, you'll need to make a second piece that your piece would like to eat.

TO MAKE ANOTHER PIECE

1. Click on the.. ..create tool.

The cursor turns into the create tool.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 8

Click to the right of your piece to place the new piece on the board.

A new piece looks like a splat of paint.

What a piece looks like is called its appearance. You can change a piece's appearance with the paint
tool.

2. Click on the.. .. paint tool.

The cursor turns into the paint tool.

Click on the new piece with the paint tool.

This opens the Appearance Editor where you can draw an appearance.

You can draw any appearance you like, or paste in any picture you draw in a painting program, then
copy and paste it in as an appearance. Here, use an appearance that takes up only one square on the
grid.

3. Click on the painting tools to draw the appearance or paste one in.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 9

The Cocoa mascot likes to eat jellybeans. Yum, yum!

You're done with the appearance. Click the.. ..appearance done button.

TO WRITE THE "EAT FOOD" RULE

You want your pieces to act a certain way when they are in a certain situation. To do this, you set up
the pieces on the board BEFORE you write the rules which tell them how to act. If your pieces are
not in the position that you want, move the pieces into position before you write the rule.

Here, we want to set up this situation: if there's food in the space to the right of your piece, it will eat
it and move right.

For this rule, move the "food" to the right of your piece.

1. Set up the board, then click the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

This opens the Rule Editor where you record a rule.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 10

2. Drag the spotlight handles to include the food piece on the right.

Now we can see what your piece wants to eat. To delete a piece out of the world, you use the delete
tool.

3. Click on the food with the.. .. delete tool.

4. Move your piece to the right.

You have now written a rule that says:

If there is food in the space to the right of me . . . then "eat" it and move to the
right.

You're done with this rule. Click the.. ..rule done button.

Now you can put out more food for your piece to eat.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 11

1. Go to the PIECE menu and select "Show Types."

If you want, you can name the type "Food" in the Types window.

2. Drag more food from Types window to the board.

Anytime you want more pieces of any type, go to the PIECE menu and select "Show Types." Then,
you can drag out any piece you want onto the board.

TRY THIS ON YOUR OWN!

Set up food all around the obstacle course, wherever your piece can run into the "food" on its right.
Soon your piece will eat up all the food you've put out.

Try writing rules for your piece to eat food placed around the blocks.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 12

Here are some rules you can try...

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

GET A COPY OF THIS WORLD

You can download the "Eating Food" world to your computer to see what the finished world
looks like. It's 23K and will take about 1 minute to download with a 14.4 speed modem.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 13

This world has the rules already written for the Cocoa mascot. You can open it and start the world.

Start a new world by copying the "Obstacle Course" world done in the "Basics" section. If you
skipped that section, download the "Obstacle Course" world and start with it to go on with
this section.

To avoid confusion, rename the new world "Moving Obstacles" before opening it.

MOVE THE OTHER PIECE

Your piece already knows how to move right and jump on and off a block. How about giving your
piece some rules to change the obstacle course? As it moves around the board, it can move
obstacles and then get around them.

In this new world, your piece will be able to move a block if there are 2 stacked, one above the other,
on its right and if there's an empty space to the left.

TO WRITE A "MOVE BLOCK" RULE

You want your pieces to act a certain way when they are in a certain situation. You can change the
situation by moving obstacles, or you can give rules to your piece to move obstacles while it moves
through the obstacle course.

Here, we want to set up this situation: if there are 2 blocks one above the other to the right of your
piece, it will move 1 block to the empty space to its left, if the space is empty.

For this rule, move your piece where there is empty space to the left and to the right. In the space to
the right of your piece, stack 2 blocks, one above the other.

1. Set up the board, then click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 14

This opens the Rule Editor where you write the rule.

2. Drag the spotlight handles to include both blocks in the space to the right of your

piece and one empty space to its left.

3. Move the top block to the empty space to the left of your piece.

You have now written a rule that says:

If there are 2 blocks, one above the other, to the right of me, move the top block to
the space to my left, only if that space is empty.

You're done with this rule. Click the.. ..rule done button.

TRY THIS ON YOUR OWN!

What if the space to the left of your piece is not empty? Then, your piece could not move one of the
Mon, Jun 23, 1997 12:11 PM
beyondforPDF.html Page 15
blocks.

Write some other rules that will let your piece move one of the blocks to a different empty spaces, for
instance, on the right side of the block or down below the block.

Here are some rules you can try...

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 16

GET A COPY OF THIS WORLD

You can download the "Moving Obstacles" world to your computer to see what the finished
world looks like. It's 23K and will take about 1 minute to download with a 14.4 speed modem.

This world has the rules already written for the Cocoa mascot. You can open it and start the world.

Start a new world by copying the "Obstacle Course" world done in the "Basics" section. If you
skipped that section, download the "Obstacle Course" world and start with it to go on with
this section.

To avoid confusion, rename the new world "Creating Obstacles" before opening it.

CREATE ANOTHER PIECE IN A RULE

Your piece already knows how to move right and jump on and off a block. How about giving your
piece some rules to build the obstacle course itself? As it moves around the board, it can create new
obstacles and then it will have to get around them.

TO WRITE THE "CREATE A BLOCK" RULE

You want your pieces to act a certain way when they are in a certain situation. You can change the
situation by adding obstacles, or you can give rules to your piece to add obstacles while it moves
through the obstacle course.

Here, we want to set up this situation: if there are 2 blocks, one above the other, to the right of your
piece, it will move up and another block will appear.

For this rule, move 2 blocks, one above the other, to the right of your piece.

1. Set up the board, then click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 17

This opens the Rule Editor where you write the rule.

2. Drag the spotlight handles to include the 2 blocks to the right of your piece.

3. Move your piece up into the empty space above it.

To create another block in the rule, you need to see all the types for this world and make a copy of the
block.

4. Go to the PIECE menu and select "Show Types."

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 18

5. Drag a copy of the block from "Types" window to the AFTER side of the rule.

Anytime you want more pieces of any type, go to the PIECE menu and select "Show Types" then
drag out any piece you want onto the board.

You have now written a rule that says:

If there are 2 blocks, one above the other, to the right of me . . . I'll move up and
another block will appear under me.

You're done with this rule. Click the.. ..rule done button.

TRY THIS ON YOUR OWN!

Write other rules that will let your piece move in other directions and make obstacles appear in the
empty spaces. But be careful, if you write too many rules that create obstacles, there will soon be no
space to move around!

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 19

Here's another rule you can try...

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

GET A COPY OF THIS WORLD

You can download the "Creating Obstacles" world to your computer to see what the finished
world looks like. It's about 20K and will take about 1 minute to download with a 14.4 speed modem.

This world has the rules already written for the Cocoa mascot. You can open it and start the world.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 20

Start a new world by copying the "Obstacle Course" world done in the "Basics" section. If you
skipped that section, download the "Obstacle Course" world and start with it to go on with
this section.

To avoid confusion, rename the new world "Making Sound" before opening it.

MAKING A SOUND

Your piece already knows how to move around the obstacle course, but for fun you could have it
make sound as it moves around. This is a good way to attract attention to something different
happening in the world.

In this world, you will write a rule for your piece to make a sound if there are 2 blocks in its way
and it can't get around it.

First, you'll need to record a sound. Then you will write the rule that tells your piece to say the sound
when it gets stuck next to 2 blocks.

RECORD A SOUND

1. Select your piece on the board (it looks dark), go to the SOUND menu and select

"Show Sounds."

This opens the Sounds window. Any time you want to see all the sounds a piece has to say, just go
to the SOUND menu and select "Show Sounds."

We want to create a new sound.

2. Go to the SOUND menu and select "New Sound."

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 21

This opens the Sound Editor for your piece with Record, Stop and Play buttons.

3. Make certain your microphone is working.

There should be "waves" coming from the speaker icon.. ..when you make a sound

into the microphone. You may want to practice the sound before you record it.

4. Click on the.. ..button to start recording and the.. ..button to stop

recording the sound.

5. Click on the.. ..button to hear the sound.

You can click on the.. ..button if you don't like the sound, and then record a new

one.

You'll have to go back to the SOUND menu and select "New Sound" to start recording again. When

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 22

you're happy with what you recorded, click on the.. ..button.

The new sound appears in the Sounds window. To avoid confusion later, you can name it "Uh Oh."

You can double-click on the.. ..sound to hear it again.

Now that your piece has a sound to say, you can write the rule that lets your piece say the sound
when the world runs.

WRITE A "SAY SOUND" RULE

You want your pieces to say a certain sound when they are in a certain situation. Sounds make your
world more fun and can be good way to show that something different is happening in the world.

Here, we want to set up this situation: if your piece is moving to the right, but there are at least 2
blocks in its way, it says "Uh Oh".

For this rule, put 2 blocks, one above the other, in the space to the right of your piece.

1. Set up the board, then click on the.. .. rule recording tool.

The cursor turns into the rule recording tool.

Click on your piece with the rule recording tool.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 23

This opens the Rule Editor where you write the rule.

2. Drag the spotlight handles to include the 2 blocks to the right.

Now you show that you want a sound to be said by your piece when the rule runs.

3. Drag the "Uh Oh" sound onto the piece. It has to go on the AFTER side of the Rule

Editor.

This says that you want your piece to say "Uh Oh".

You have now written a rule that says:

If I'm moving right and there are 2 blocks, one above the other, to the right of me .
. . then I'll say "Uh Oh".

You're done with this rule. Click the.. ..rule Done button.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 24

AN IMPORTANT NOTE ABOUT SOUNDS

If you dragged the Cocoa mascot's "Uh Oh" sound onto the Block in the rule, the Block wouldn't
say "Uh Oh." When you're making sounds, be careful to check whose Sounds you're using and
which piece you're dragging that sound onto.

TRY THIS ON YOUR OWN!

Now that your piece says something in one situation, you can record other sounds to have it say other
things in other situations. If you add another of the same piece into the world, you can have them
meet and say "Hello" or "Goodbye".

Here are some rules you can try...

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 25

SAVING YOUR WORLD

You have 3 options for saving Cocoa worlds.

Go to the Saving Options page to see how.

GET A COPY OF THIS WORLD

You can download the "Making Sound" world to your computer to see what the finished
world looks like. It's 43K and will take about 1 minute to download with a 14.4 speed modem.

This world has the rules already written for the Cocoa mascot. You can open it and start the world.

GROUPING RULES INTO A RULE SET

If you've built the worlds described in the Beyond the Basics section, you've written many
different rules, some for the same situation: when there are 2 blocks, one above the other to the right
of your piece. All rules are checked from the top to the bottom of the rule list. But, you may not
always want your piece act that way.

You can change the way rules are checked to change your piece's behavior.

You can put some rules together in a Rule Set to give your piece different behavior.

TRY THIS ON YOUR OWN!

Open the Rules window by double-clicking on a piece.

Then click on the.. .. Rule Set tool.

The cursor becomes a Rule Set tool. Click in any white space between the rules.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 26

This creates an empty box that you can put rules into and change the way your piece acts.

Now, you can drag rules into the rule set, for instance:
Move a Block

Create a Block

Say "Uh Oh"

Close the rule set by clicking on the triangle next to the rule set name.

The rules are kept together and separate from the other rules in the rule list.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 27

Notice that there are rules below the rule set. Because the rules are checked from the top to the bottom
of the rule list, the rules below the rule set will only be checked if none of the rules inside the rule set
work or if you choose a different rule set type.

You can change how the rule set works:


Put the pointer over the options and mouse-down to see the pop-up menu.

Choose one rule set option and run the world to see how the piece acts differently, depending on
which rule set option you choose.

Do First Match finds the FIRST rule in the rule set that works, it performs the actions and then
another piece gets a turn.

When to use this: Keep rules together if you want one set of rules to be checked in the order that
they are listed, but separately from all other rules in the rule list outside the set. For instance, put all
of your piece's "Move" rules in a Do First Match rule set. If you want it to move right every time that
it can, move the "Move Right" rule to the top of the set.

Randomize and Do First: the order of the rules in the rule set CHANGES each time the piece
gets a turn. It finds the first rule that works, it performs the actions and then another piece gets a turn.

When to use this: Sometimes you want your piece to act in an unpredictable way. For instance, if
you put all of your piece's "Move" rules in a Randomize & Do First rule set, it will move in different
directions rather than the same direction on every clock tick.

Mon, Jun 23, 1997 12:11 PM


beyondforPDF.html Page 28

Do all and Continue: the rule order stays the same, but it finds ALL the rules in the Rule Set that
work, it performs ALL the actions in those rules that it can and then it GOES ON to check the rules
that are below the Do All & Continue rule set to see if they work.

When to use this: Best used to keep track of or change variables leaving other rules outside a Do
All & Continue rule set. For instance, you can "Add 1 to Age" so that your piece will get older, and it
will GO ON to check if it can do something else on the same clock tick.

GET A COPY OF THIS WORLD

You can download the "Grouping Rules" world to your computer. It's about 28K and will
take about 1 minute to download with a 14.4 speed modem.

Mon, Jun 23, 1997 12:11 PM


Saving Options
You can save your Cocoa world in 3 ways:

As a Cocoa world which can only be opened with Cocoa

As a web page which can be viewed with a web browser

As an autoplaying world which can be viewed on any Macintosh

Save World or Save World As...

Type in the name you'd like to use for your world or this version of your world.
Saving Worlds this way allows you to open them in Cocoa and change how they work later. The
other two formats don't let you do this.

Save for Internet

First, fill in the information to be shown in the web page

After you fill in the information, you can "Save for Internet"
A ".cco" media file and a ".html" web page file will be created. The web page can be opened with a
web browser and the world will be viewed inside the web page.

Build Autoplayer

Type in the name you'd like to use for this AutoPlayer of your world
Word List

World
In a world, pieces can act in certain ways only when in a certain situation. Pieces don't act the same way all
the time. How they act depends on the situation you create in the world. You write rules to control how
pieces act in the world.

Board
The Board is the area where the pieces act. The pieces can only act in the order which they were put out on
the board.

Piece
Anything that can appear on the board, whether it has rules or not, is a piece. When you create a piece,
you're actually creating a "Type" of piece, and the piece on the board is a copy of that Type of piece. You can
have many pieces of the same Type, all acting on the Board at once. You can move, create, delete, copy, and
name a Type and a Piece.

Rule
A rule is a "plan": it has a "Before" situation to check (the left side of the Rule) and an "After" situation with
actions to do (the right side of the Rule). All the rules for a piece are listed in the Rules window. The rules
are in the order that will be checked for the piece to act. You can create, delete, name, and reorder a rule.

Clock Tick
In one clock tick, every piece gets a chance to test its rules and do what it can. A clock tick can run either
forward so all pieces can try to do something or it can run backward so all pieces UNDO everything they did
on the last clock tick.

Appearance
What the piece looks like. You can draw an appearance in Cocoa or paste one in that you drew and copied
from a drawing program. Pieces can have many different appearances.
Grid
The Board is separated into a grid of squares like a checkerboard. When you draw an appearance or write a
rule, you can see the grid lines in the background. When pieces move around in a world, they can only move
from square to square on the grid.

Painting Tools
A set of tools for drawing your piece's appearance; for example, pencil, paintbrush, and eraser. There is a
PAINT menu that gives you choices for flipping and rotating the part of the drawing you've selected.

Spotlight (Handles)
The Spotlight lights up the area around your piece when you're writing a rule for it. You drag the handles out
to show more of the board and to include pieces that should be in the rule. Your piece sees what's in the
spotlight and it ignores anything outside the spotlight.

Variable
Information about pieces such as their appearance or what they said. Pieces can track different variables and
the variables can keep different kinds of information. You can create, delete, move, and name a variable.

Delete tool
The delete tool is used to delete anything that you want to delete out of your world, for example, pieces or
rules.

Sound
What the piece can say. You can record new sounds or import sounds from a file that is not open.

Rule Set
Put rules into a Rule Set if you want one set of rules to be checked separately from all other rules in the list
outside the set. There are 3 types of rule sets: Do First Match, Randomize & Do First, and Do All &
Continue.