Introduction to CSCI 1
description
Transcript of Introduction to CSCI 1
![Page 1: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/1.jpg)
Introduction to CSCI 1
![Page 2: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/2.jpg)
How this class will workhttp://users.drew.edu/sbradsha/CSCI1-Spring2007/
![Page 3: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/3.jpg)
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)
![Page 4: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/4.jpg)
The basics of programming
A computer program is a set of instructions that tell the computer what to doIt is important to write your programs in an “elegant” fashion.Huh? Two primary functions:
To tell the computer what to doTo tell other humans what you want the computer to do
![Page 5: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/6.jpg)
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
![Page 7: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/7.jpg)
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
![Page 8: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/8.jpg)
Alice concepts
![Page 9: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/9.jpg)
Concept: Virtual world
Video game or simulation implemented in 3D
2D vs. 3D
![Page 10: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/10.jpg)
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.
![Page 11: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/11.jpg)
Concept: ObjectAn "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 performtasks it can carry out
![Page 12: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/12.jpg)
Object Parts
Objects may be composed of parts
![Page 13: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/13.jpg)
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
![Page 14: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/14.jpg)
Concept: 3 Dimensions, 6 Directions
A 3D object has 3 dimensions
height, width, depth
6 degrees of freedom (directions of movement)
![Page 15: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/15.jpg)
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
![Page 16: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/16.jpg)
ClassObjects are categorized into classes
Each object is an instance of the class.
All objects in a class have similar properties and generally can perform the same tasks.
Person
Dogs
peter
mary
paul
spike
scottie
fluffy
![Page 17: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/17.jpg)
Appendix A: Exploring Alice
World 1:Open World…Week1AppendixA_FirstWorld.a2w
Play
![Page 18: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/18.jpg)
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.
![Page 19: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/19.jpg)
Object Parts: A closer look
![Page 20: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/20.jpg)
Introduction to the "code"
Look at Hare in the Object treeExpand 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
![Page 21: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/21.jpg)
Modifying code
Let's change the movement to go left and right instead of forward and backward.
PLAY
![Page 22: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/22.jpg)
Modifying code
Let’s make the RIGHT ear move.
![Page 23: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/23.jpg)
Modifying code
FinallyLet's change this one last time so that the RIGHT ear moves forward and back.
PLAY
![Page 24: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/24.jpg)
Interactive World
Open New WorldOpen AppendixA_DancingBee.a2w
PlayPress Up-Arrow key
Press space bar
![Page 25: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/25.jpg)
Two types of worlds
Movie Worldmovie runs from beginning to end
Interactive Worldyou choose how animation runs (events)
![Page 26: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/26.jpg)
Creating your own world
File menuNew Worldgrass template
Save World As MyFirstTryNavigate to the appropriate folder
![Page 27: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/27.jpg)
Creating your own world
Add Objects
Search Gallery allows you to choose objects
Click Folder
![Page 28: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/28.jpg)
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
![Page 29: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/29.jpg)
Galleries
Classes (3D models) are found in the galleries Local gallery (installed with the software)
Minimum or complete options
Web gallery
![Page 30: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/30.jpg)
Choose Local Gallery
PeopleAddsnowMan (2 ways to add to world)
Drag snowman to world
Click and Add Instance to world
snowWoman
![Page 31: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/31.jpg)
Controls
Click on snowman and experiment with controls.
Click on snowWoman and check "affectparts"
delete her hat.
![Page 32: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/32.jpg)
Controls
![Page 33: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/33.jpg)
Controls
Camera
Top
Side
Front
![Page 34: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/34.jpg)
More controls
Moving the camerachanges the view of the world
Go slowly.
![Page 35: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/35.jpg)
New worlds
Add all objects when you create the world.
Use mouse and camera controls to arrange objects at the scene.
![Page 36: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/36.jpg)
Assignment
Read (before the next class session)
Chapter 1 Section 1, Introduction to Alice
Section 2, Alice Concepts
Tips & Techniques 1, Special Effects
![Page 37: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/37.jpg)
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
![Page 38: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/38.jpg)
OOP
An object can be something in the physical world or just an abstract ideaAirplane (auto-pilot program)A bank transaction (ATM software)The code that manipulate the properties of an object are called the object’s methodsWe can think of an object as a collection of its properties and methodsThe values stored in the properties of an object are called collectively know as the object’s stateOOP algorithms define interactions between objectsAn OO program uses objects as tools to do its work
![Page 39: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/39.jpg)
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
![Page 40: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/40.jpg)
Welcome to Alice! dialog
![Page 41: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/41.jpg)
Tutorials tab
![Page 42: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/42.jpg)
Recent worlds tab
![Page 43: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/43.jpg)
Examples tab
![Page 44: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/44.jpg)
Open a world tab
Navigation
Folders
Files
Controls
![Page 45: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/45.jpg)
Object Tree
Details Area
World WindowEvents Area
Editor Area
![Page 46: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/46.jpg)
Object Tree
![Page 47: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/47.jpg)
Details Area
![Page 48: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/48.jpg)
Editor Area
![Page 49: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/49.jpg)
Events Area
![Page 50: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/50.jpg)
event trigger
event handler
event handler
event handler
![Page 51: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/51.jpg)
World Window
![Page 52: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/52.jpg)
![Page 53: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/53.jpg)
![Page 54: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/54.jpg)
Trashcan and Clipboard
![Page 55: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/55.jpg)
Menus
![Page 56: Introduction to CSCI 1](https://reader036.fdocuments.net/reader036/viewer/2022081514/56813c7c550346895da616f4/html5/thumbnails/56.jpg)
In-class exercise 1
On the course web site under week 1