Download presentation
Presentation is loading. Please wait.
Published byHannah Maxwell Modified over 9 years ago
1
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop
2
Session 0
3
Workshop Expectations This workshop is designed to introduce programming concepts through the use of the intuitive programming environment of Alice. Each of the seven Alice sessions will focus on one or more of these concepts. Throughout the workshop, there will be a chance for you to use your new skills to create teaching aids for your subject while introducing programming concepts to your students.
4
Alice Overview Created by Carnegie Mellon in 1999 100% GUI based programming environment Object-oriented Multi-threaded Runs on Windows and Mac Free!
5
Set up environment Let us create our first example program. This program will consist of adding an object to the world and making it move. Open Alice by double- clicking the icon on the desktop Click the templates tab Select one of the preset environments Click open
6
Alice Interface The Alice interface is divided into five major sections: The section on the upper left is called the object tree. This contains a list of all the objects that currently exist in the world. The lower left section is the object details area and shows information about the currently selected object. The upper center section is the world window. This provides an interactive view of how the world will look when ran. The top right corner is known as the events area. Most methods of interaction with the user occur here. The remaining section is the editor area. This is where the actual programming takes place.
7
Objects in Alice Alice, like many other programming languages, is object oriented. Objects provide a basis for program structure and serve to organize and simplify the design. Programming with objects is often intuitive because of the nature of human interaction with the world. Objects consist of three basic elements: ◦Properties – also known as variables, these are the characteristics of the object much like hair color and height are for us. These will be discussed in greater detail during session 4. ◦Methods – allow objects to do things such as move, turn, resize, etc. Methods will be discussed in greater detail during session 5. ◦Functions – allow objects to do calculations. In session 5, we will create a function that calculates the rotation of a vehicle wheel in relation to the distance it moves.
8
Default Objects in Alice All Alice programs contain at least four objects. These are: ◦World - think of this as the virtual universe. All other objects exist in and are “owned” by it. Unlike other objects, it is impossible to move the world object. ◦Camera – this supplies the view used by the world window and is determined by the placement and orientation of the camera object. ◦Light – as the name implies, this object provides a source of light to the scene and can be moved or otherwise manipulated to alter the brightness and/or shadows in the world. ◦Ground – the xz-plane that serves as a reference point for the user to place other objects.
9
Add Object to World To enter object management mode, click the green button in the lower right corner of the world window. Find a vehicle object with wheels (not the ambulance) and drag it to the ground in the window above. For advanced positioning instructions, please refer to the presentation notes.
10
Object Manipulation Tools Allows you to select an object and move it on the horizontal plane Moves an object on the vertical plane Rotates an object around the y-axis of the world window Rotates an object around the x-axis of the world window A combination of the previous two tools. It is very hard to control and should probably be avoided Increases or decreases the size of an object Creates a clone of an object
11
Renaming Object In the object tree, find the newly added object, right-click it, click “rename,” and enter a new name. The new name should be short, descriptive, and meaningful.
12
First Program: Moving an Object Let’s learn how to use the block. Orient the vehicle so it looks as though it will be driving to the right. You probably will need to move the camera and/or adjust the size of the vehicle. Select your object and move it as far as you can to the left of the screen. It is time to close object management mode in order to open the method editor. To do this, simply click the button. To make this object move, select it by left clicking the vehicle, click the methods tab in the object details area and drag a move block to the editor area.
13
First Program cont. A drop-down menu will appear and you can choose the direction the object will move; mouse-over “forward”. You should see another drop-down menu where you can select how far it will move, select ½ meter for now. Now we are ready to test our first program. In the top left- hand corner you will find the button. Anytime you want to test your project, simply click this button. If your object didn’t move a satisfying distance or it didn’t move in the correct direction you can edit this by left clicking the down arrow to the right of the attribute you want to change. A menu will drop down and you can choose a new value.
14
Multithreading Now we have our vehicle moving to the right, it is time to make the wheels turn or rotate while the vehicle is moving. To make two or more things happen at once we use a programming convention known as multithreading. In order to affect only the wheels of your vehicle, click the plus button to the left of it in the object tree. This will make the sub-parts of the object visible which will allow you to manipulate them individually. For now, just select one of the wheels (preferably one that can be seen in your world window) To make the wheel turn, drag a block and place it in the editor area. Choose a direction for it to turn and test your program. If the wheel doesn’t turn properly, change the direction or try the.
15
Multithreading cont. Even though we have the vehicle moving and the wheel rotating, it still isn’t perfect because the vehicle moves, then the wheel rotates. The reason? Alice, like most other programming languages, processes statements starting from the top and moving down one by one. In order to have the vehicle move while the wheel rotates, we must use a new block. Place a container into the method editor and place the move and turn blocks inside it. This brings up the subject of multithreading. Many programming languages take advantage of this functionality. It allows the programmer to make multiple things happen at the same time. For example, the vehicle will move at the same time the wheel is turning. Now let’s test this and make sure everything works properly.
16
Project 0 Now that we know how to use a do together container to implement multithreading, try to get the other wheels of your vehicle spinning. They should all spin at the same time. This may take some playing around, but it is possible. You should also change the wheels rate of spin to look as realistic as possible in relation to the ground. In session 5 we will explain how to do this more efficiently.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.