Tuesday, February 02, 2010

Introduction to Programming: Starting Out With Alice Chapter 1 – Introduction to Alice and Objects

 

1.1 What is a computer program?

A computer is a device that follows instructions. Not specific enough because I cannot tell it to make my breakfast for me. How about a computer is a device that follow instructions for manipulating and storing data.  Much more precise. It does these instructions by a set of commands called programs.  So by default, a computer program is a set of instructions that the computer follows to perform a task.

1.2 Algorithms and Programming Languages

An algorithm is a well defined logical set of steps that must be taken in order to perform a task.  They must be done in order. If we wanted to get information on a paycheck:

  1. Display “how many hours worked”
  2. User enters data
  3. store information in memory
  4. Display “how much do you get paid”

and so on till the entire instructions are done.

Computers work with machine language, 1’s and 0’s so this will not help the machine.  It does help organize our thoughts though. To get from the algorithm to the machine language we use a programming language.   Like a regular language (French, English, etc.) we must stick to the set of rules (syntax) and the words that are allowed to be used. This listing is then sent through a compiler to make an executable file to run or an interpreter to take each line and then give the results of following that instruction. When we convert the algorithm to instructions the programming language can understand we are writing statements. These can be done in a programming environment or in a simple text editor.

1.3 Learning to Program with Alice

We will be using Alice to write programs. It allows us to create 3-D worlds to learn not programming but programming concepts. It is not designed for professional programming but for teaching programming concepts. Rather than mess up with syntax we will pick from items already set up for us. [The rest of 1.3 is about installing and using Alice for the first time.]

1.4 Objects

Objects

In Alice and object is an item. In the sample snowLove given with the software, there are three objects, a snowman, a snowwoman and an island. 

Properties

Each object can have properties to define it. For example, the Snowman may have a normal color, the Snowwoman a pink color.

Methods

A method is an action that an object can do.  The Snowman can walk would be an example in Alice. In a regular program it might be some calculations that can be done. Usually methods are made up of several steps.

Objects Can Be Made of Other Objects

Objects very often are made up of other objects.  The snowman of three snow parts  called head, middle and bottom.  The middle might have a right arm and left arm object.  So to make objects you will often need other objects.

The World is an Object

Even the world that you create in Alice is an object that can be manipulated. 

1.5 Classes and the Alice Galleries

Objects are made from classes.  A class is a set of specifications that decide an object.  When we use a world in Alice we use a collection of objects

Classes

A gallery does not contain objects in Alice, they contain classes.  A class is a description of an object written in programming statements.  Just as you have a blueprint for a house and can make several houses from it, you can have a class for an item and make many objects from it. The house may be made of bricks or wood, but it is the same blueprint, just certain things modified. So it is with objects and classes. Objects are sometimes referred to as instances.

The rest of 1.5  Classes is a tutorial in creating a world and adding objects

1.6 3D Objects and the Camera

Simple computer games are what we define as 2 dimensional.  That is they have left and right as well as up and down.  In the Alice environment we have height (up and down) and width (left and right), but we have depth as well.

The Camera

The camera in Alice is placed in such a way as to give you a view of the world.  The camera can move:

  • Left, right, up and down
  • forward, backward, rotate left and rotate right
  • Tilt

Modifying Objects in 3D

In Alice you can do the following things to objects:

  • move
  • resize
  • rotate
  • tumble
  • copy

Along with that there is a button that allows you to move an object freely. There is also a checkbox that will allow any things done to affect just the object itself or the whole object that it is a part of.

Rotation, Center Points and Orientation

Any modifications that you do will rotate around the center point of the object.  When you select an object it will show three axis's. Where the three meet is the center point of that object. This point is determined by the person who created the object in the first place and is usually a logical placement.

Pitch, Roll,  and Yaw

Pitch – movement that an object makes when it rotates around its left/right axis.

Roll - movement that an object makes when it rotates around its forward/backward axis. 

Yaw - movement that an object makes when it rotates around its up/down axis.

Single View and Quad View Modes

It is possible in Alice to view the normal world view but also to look at the world from four angles.  They would be, top, left right and camera angle. When this happens you get two new buttons to work with: a zoom button to move in and out on each of the three new screens;  and a scroll button that will let you scroll the window in the new screens.

Using Coordinates to Determine an Object’s Location

By clicking on the camera object and choosing the properties tab you can see the X, Y and Z coordinates.  The center of the world is 0,0,0 and will change as you change the view.

1 comment: