560 likes | 661 Vues
Introduction to CSCI 1. How this class will work. http://users.drew.edu/sbradsha/CSCI1-Spring2007/. Alice. A modern programming tool 3-D graphics 3-D models of objects Animation Objects can be made to move around the virtual world (a video game or simulation implemented in 3-D).
E N D
How this class will work • http://users.drew.edu/sbradsha/CSCI1-Spring2007/
Alice • A modern programming tool • 3-D graphics • 3-D models of objects • Animation • Objects can be made to move around the virtual world (a video game or simulation implemented in 3-D)
The basics of programming • A computer program is a set of instructions that tell the computer what to do • It is important to write your programs in an “elegant” fashion. • Huh? • Two primary functions: • To tell the computer what to do • To tell other humans what you want the computer to do
Elegant programs • A program is elegant if other humans can easily understand and appreciate the intentions of the original programmer. • Your goal should be to make your program easy to read, even by someone not a programmer • Should not require any head scratching
Programs composed from simple ideas • A list of instructions like a recipe • Ifs (e.g., if it is raining, take an umbrella) • Repeating behavior (e.g., while there are cookies on your plate, keeping eating cookies) usually called looping or iteration • Breaking things up into smaller pieces • Compute a result
Simple ideas, cont’d • Programming is just using these ideas in various combinations • Most computers understand only about 100 distinct instructions • The millions of programs that run on a computer use these instructions in different orders and combinations • Like chess in this way
Concept: Virtual world • Video game or simulation implemented in 3D 2D vs. 3D
Virtual world, cont’d • Virtual worlds provide an environment that allow us to simulate the type of interactions with which we are familiar in the real world.
Concept: Object • An "object" is • any thing that can be identified as unique from other things • How is an object unique? • has a name • has properties: • width, height, color, location • can perform actions (methods): • associated actions it can perform • tasks it can carry out
Object Parts • Objects may be composed of parts
3D models • In Alice, nearly all objects are represented by 3D models • These are the animals, people, cars, anvils, etc. that you add to a world • 3D models are found in the Alice galleries • Alice is not a 3D graphics drawing program • With the exception of he-builder and she-builder we use pre-defined models
Concept: 3 Dimensions, 6 Directions • A 3D object has • 3 dimensions • height, width, depth • 6 degrees of freedom (directions of movement)
Concept: Center of an object • At the center of mass • Where it stands on the ground • Where it is held • Distance between objects is measured from their centers • An object’s position in the world is given by its center
peter Person paul mary spike Dogs scottie fluffy Class • Objects are categorized into classes • Each object is an instance of the class. • All objects in a class have similar propertiesand generally can perform the same tasks.
Appendix A: Exploring Alice • World 1:Open World…Week1AppendixA_FirstWorld.a2w • Play
Appendix A: exploring Alice • Notice the Object Tree contains all of the objects in the world. • The camera and the light are in every Alice word.
Introduction to the "code" • Look at Hare in the Object tree • Expand to find the hare's ears • Notice that the hare's left ear moves forward and back in this animation. • Let's modify this animation
Modifying code • Let's change the movement to go left and right instead of forward and backward. • PLAY
Modifying code • Let’s make the RIGHT ear move.
Modifying code • Finally • Let's change this one last time so that the RIGHT ear moves forward and back. • PLAY
Interactive World • Open New World • Open AppendixA_DancingBee.a2w • Play • Press Up-Arrow key • Press space bar
Two types of worlds • Movie World • movie runs from beginning to end • Interactive World • you choose how animation runs (events)
Creating your own world • File menuNew World • grass template • Save World As MyFirstTry • Navigate to the appropriate folder
Creating your own world • Add Objects • Search Gallery allows you to choose objects Click Folder
Objects • An "object" is • any thing that can be identified as unique from other things • How is an object unique? • has a name • has properties: • width, height, color, location • can perform actions (methods): • associated actions it can perform • tasks it can carry out
Galleries • Classes (3D models) are found in the galleries • Local gallery (installed with the software) • Minimum or complete options • Web gallery
Choose Local Gallery • PeopleAdd • snowMan (2 ways to add to world) • Drag snowman to world • Click and Add Instance to world • snowWoman
Click on snowman and experiment with controls. Click on snowWoman and check "affectparts" delete her hat. Controls
Camera Top Side Front Controls
Moving the camera changes the view of the world Go slowly. More controls
New worlds • Add all objects when you create the world. • Use mouse and camera controls to arrange objects at the scene.
Assignment • Read (before the next class session) Chapter 1 • Section 1, Introduction to Alice • Section 2, Alice Concepts • Tips & Techniques 1, Special Effects
Object-oriented programming and Alice • In designing modern software we work from an algorithm. • An algorithm is a plan for solving a problem by following a sequence of steps • To help manage the growing complexity of software, computer scientists introduced the concept of OOP some time ago
OOP • An object can be something in the physical world or just an abstract idea • Airplane (auto-pilot program) • A bank transaction (ATM software) • The code that manipulate the properties of an object are called the object’s methods • We can think of an object as a collection of its properties and methods • The values stored in the properties of an object are called collectively know as the object’s state • OOP algorithms define interactions between objects • An OO program uses objects as tools to do its work
Exploring the Alice Interface • Alice is an example of an Integrated Development Environment (IDE) • An IDE is a computer program used to write other computer programs • The Alice IDE is often called the Alice interface
Open a world tab Navigation Folders Files Controls
World Window Events Area Object Tree Details Area Editor Area
event trigger event handler event handler event handler