Alice 3.1 Tutorial Part 4: Begin to Program - Alice Programming

Now, you have your objects placed on the scene, you can start programming.
Remember to save your work very often, to avoid losing your work if something happens crashing or hanging your system or Alice.
You have seen the Alice Code Editor earlier in Getting Started with Alice. The Alice programming involves dragging and dropping the procedure tiles from the methods panel to the code editor.  First, you need to select the object to be animated from object tree (see image below). 
Once you select an object, the procedures predefined for that particular object class will be listed in the methods panel.
The procedure will show the object name followed by the procedure name and arguments. The programming arguments initially displayed with ??? are additional information required to perform that particular procedure.
In the beginning the edit pane will have a shaded rectangle with Drop statement here where you can drag and drop the required procedures. Later when you try add more codes, it will guide you the placement with a green horizontal line indicating where the code will be placed once you drop it.

Let's have a demonstration of dragging and dropping a code tile. We have a bunny added to the scene, so let's now make him move.


In the above video you can see how the additional information like the direction to move and the distance to move was provided to the code statement.
Code Statement
The highlighted parts indicate that these values can be modified as required by clicking on the small arrow neat to them. The code tiles can be moved by clicking on the leftmost dotted area of the tile and dragging and dropping it. Pressing Ctrl key while moving the tile will make a copy of the tile. 

You can remove a tile by right-click->Delete.
The code tiles can also be disabled by Right-click->Is enabled.
The add detail button at the end of the tile lets you provide additional option for the statement. For example we have provided duration 2.0 here so that the movement will  be slow.
Once you have added the procedure tile to the code editor, click on Run button to test it.

Now take a look at the other move procedures available for Bunny.

Move: This procedure can be used to move the object in all six directions. While dropping the statement you will have to select the direction and distance.
MoveToward: Moves the object towards another object. Here you will have to select the object to move toward to and the distance.
MoveAwayFrom : Similar to the move toward this will move the object away from the other object.
MoveTo: Is used to move an object to another object. The object will move to the centre of the target you specify. You can adjust the position/distance using the mathematical options available (will be discussed later)
MoveAndOrientTo: This one is same as MoveTo statement, but here the orientation of the object will be adjusted to the target object..
Place: Used to place an object in relation to the other like in front of, right of, left of, below, above and behind.

So go ahead, try the move procedures!






No comments:

Post a Comment