image Tutorial on Describing Setting 2 - Aligning

Instead of randomly scattering characters on the canvas, you have the option of placing the characters in a more organized fashion by using the keywords 'align' or 'spread'. Consider the following examples:
Thirty carrots are spread across the top.
This will place the carrots in neat rows across the top of playing area, as shown. If the word "spread" was replaced with "scattered", the carrots will be randomly placed across the top. image
There are twenty carrots.
The carrots are spread 5 by 4 in the area.

You can also specify how many rows and columns you'd like to arrange the carrots. In this example, the carrots will align into 5 rows and 4 columns. image
There are four rabbits and 20 carrots.
They are spread 5 by 4 in the area.

In this example, only the carrots will be spread out in a 5 by 4 fashion. The rabbits will be placed randomly. Use pronouns carefully. It is always better to spell out the characters clearly. A better statement would be: There are four rabbits and 20 carrots. The carrots are spread 5 by 4 and rabbits are scattered in the area. image

Finally, what if we say that there are 20 carrots, and they are spread 6 by 3. What will happen since 20 is not equal to 6 times 3? There will still be 20 carrots, the 6 by 3 is only a guide on how to spread the carrots out.

The words 'spread' and 'align' should be used sparingly. They are only for approximating the initial positions of the objects. Instead, use the map textbox to more accurately position your objects. This will be discussed in the next Tutorial.


Try it yourself: Try typing in the following sentence into the textbox on GameChangineer, then click "Execute" near the bottom of that page to generate the code for your game plan. If there are no typos and everything is understood, click the button at the bottom to see your code in action!

There are 15 foxes spread near the top of the playing area.

Quiz: How would you describe the scenario where 30 rabbits are placed in an orderly fashion in the bottom half of the area?


Programming Concepts (optional material):
In the previous tutorial page, we introduced the concepts of objects, instantiation, and attributes associated with an object. When we wish to scatter or spread the instances of an object, we say that we need to assign values to the position attribute for the object. The actual implementation of scattering (the program code necessary to do that) is hidden from you. When we focus on the attributes while ignoring the implementation details, we are applying the concept of "abstraction." We use abstraction in our everyday lives as well. For example, when we say that we are eating a sandwich, the details of eating (chewing, swallowing, digesting, etc.) are hidden. The exact mechanics of these details are not needed for one to understand the act of eating. Can you think of another example of abstraction in everyday activities?

Abstraction offers a number of benefits. Most importantly, it allows the programmer to focus on the big picture of the interactions among objects without getting bogged down with the low-level details of how the interactions are implemented. Thus, even if the implementation for an abstract method changes, the big picture remains intact. Thus, in saying "The carrots are scattered," we do not need to concern ourselves with the exact fashion in which they are scattered, just that we know they are scattered somehow. We will see more of the concept of abstraction later in other methods that involve interactions among objects.

In fact, in using plain English to write your game-plan program, the low-level code that implements the methods (used to manipulate the attributes for each object) is hidden from you and is automatically generated. This allows you to focus on the big picture of how you want the objects to interact. Abstraction plays a critical role in writing large programs.



Next page

Tutorials Home