23
Programming in Alice

Programming in Alice

  • Upload
    lolita

  • View
    61

  • Download
    0

Embed Size (px)

DESCRIPTION

Programming in Alice. What is Alice. A modern programming tool purpose of tool, learn how to program, write algorithms 3-D graphics 3-D models of objects Animation Objects can be made to move around virtual world (a simulation or a video game. Alice is free. Alice is written in Java - PowerPoint PPT Presentation

Citation preview

Page 1: Programming in Alice

Programming in Alice

Page 2: Programming in Alice

What is Alice • A modern programming tool

– purpose of tool, learn how to program, write algorithms

– 3-D graphics– 3-D models of objects

• Animation– Objects can be made to move around virtual world (a

simulation or a video game.

• Alice is free.• Alice is written in Java

– www.alice.org

Page 3: Programming in Alice

Memory Management• Alice automatically manages memory• But, writing and testing an animation is an

intense load on the computing system – a crash can occur.

• Best solution: • Alice (the program) reminds you every so often

so save your work• save your programs often!• if working in lab when you logout the computer is

wiped -> save to your account or to a backup system such as a memory stick

Page 4: Programming in Alice

Details area

Shows methods available for objects. You can create new methods

Object Tree

Contains a list of objects in the world

Events Area - when you wants things to happen (when to make objects do things.

Editor Area - put your program code together

World Window – shows world you are building

Page 5: Programming in Alice

The World

• Alice Programs / Movies take place in a virtual world

• When you start a new world in Alice you select the background

•The world consistsof a sky and the ground•Can’t be changed aftercreating the world•the world is not infinite

Page 6: Programming in Alice

Objects in Alice

• Objects already exist. Hundreds of them

Page 7: Programming in Alice

Objects

• What is an object?– collection of data and operations in which data can be

accessed and modified.

Objects have two things: State & Behavior State - has a name, has properties-width, height, color,

location, age, id#

Behavior - associated actions it can perform• tasks it can carry out – things it knows how to do ((barking,

fetching, wagging tail).

Page 8: Programming in Alice

Where Do Objects Come From?• They are pre built

– creating 3D objects is another area of computing and graphic design

• Sources of 3D objects – the local gallery that comes with the software

– Alice web gallery

• How are objects added to the world?

•http://www.alice.org/index.php?page=gallery/index

Page 9: Programming in Alice

Objects are categorized into classes

• Each objects is an instance of the class

• All objects in a class – have the same properties– generally can perform the

same tasks

Penguins

Dogs

Skipper

Kowalski

PrivateSnoopy

Odie

RenOpus

Rico

Class is like a cookie cutter

Cookie Cutter (class) makes objects Like it.

Page 10: Programming in Alice

Classes & Objects

• Class - a template that describes the state and behavior associated objects (instances) of that class.

• Instance - the actual object created at runtime. Lassie would an instance of the dog class.

• instantiate - to create an object from a class

Page 11: Programming in Alice

Behaviors of objectspenguin class

Behaviors of an object are the methods (actions) it can perform.

Located under the methods tab.

Page 12: Programming in Alice

Properties of objects

penguin class

Properties of an object are the things it knows about itself and they are stored in variables.

Located under the properties tab

Page 13: Programming in Alice

Adding Objects

• Click on the green “Add Objects” button

• World expands and local gallery displayed

Page 14: Programming in Alice

Adding Objects

• Local gallery divided into a directory based on subject

• add instances of objects to world by – dragging and dropping or – click on object and select add instance option

Page 15: Programming in Alice

Objects in the World

penguin class penguin objects in a virtual world

Instances of the penguin class

Page 16: Programming in Alice

Objects in the World

• The Objects that are present in the current world are listed in the Object Tree

• The top left panel in the Alice programming environment

• Every world comes with a light, a camera (point of view for the movie whenplayed), and the ground

Page 17: Programming in Alice

Object DimensionsProperties it knows:

• Objects in Alice worlds are 3 dimensional

height width depth

Page 18: Programming in Alice

Object Position

• Objects – are positioned in 3-D space– Have six degrees of freedom (directions of movement)

Page 19: Programming in Alice

Methods: programmed procedure that is defined as part of a class and included in any object of that class.

Ice Skater Object

Two

methods

parameter

Page 20: Programming in Alice

1. What is a method:

Organized block of code that will perform a specific task.

2. What is a parameter: Extra information that a method needs to execute.

Parameter is the ( )

The data inside the parameter is called arguments.

(forward, 3)

Method name

Page 21: Programming in Alice

Changing arguments in the parameter

You change the parameter information by clicking on the argument you want to change and selecting the amount or use other to type in an amount.

Page 22: Programming in Alice

Exercises

Log on to Alice.

Complete the ice Skating tutorial in Alice.

Page 23: Programming in Alice

Complete Sequential Program

• Complete the program Maze Sequential Programming.