Presentation is loading. Please wait.

Presentation is loading. Please wait.

Time to upload Virtual something.

Similar presentations


Presentation on theme: "Time to upload Virtual something."— Presentation transcript:

1 Time to upload Virtual something.
Computer Science I Time to upload Virtual something. Compilation. Compile versus interpret. Strong typing. Family Collage. Libraries. Classwork/Homework: Finish and upload Virtual something. Explore libraries.

2 [step back] The Processing Development Environment (PDE)
Editor for code Compile (translate) sketch code. This will find certain errors (syntactic errors) and give hints. Only continue if no errors Link together that code and anything built-in or in imported libraries May discover errors Run (Execute) the result. May discover errors

3 Syntactic errors vs semantic errors
Finding errors is good! Let PDE ("the computer") do that work. Finding semantic errors is difficult.

4 Compile versus Interpret
Some programming languages are interpreted. JavaScript (used with HTML) is translated one statement at a time, during execution. Positive features of interpreted languages (JavaScript): Source code visible. Flexibility in typing. With HTML JavaScript, you may see the result each time. Can use Web Console for some hints on errors. Positive features of compiled languages (Processing): More complete and better checking and hints. Executable (product of compilation) fast.

5 Libraries All programming languages have ways to add features. It is often called Libraries. The processing.core Library was what we added to Java. In Processing, to add Library, need to Sketch/Import Library … find the Library. Select. In your code: import ….

6 Processing … will make hint that you need to import library.
Recall comments on import processing.core.*; Note: sometimes error is that programmer made typo in method name.

7 Family collage example
Objective: build program that shows items on the screen rectangle, picture, video clip Let user drag item, duplicate item, remove item. These operations indicated by certain keys. Plan: define Item class, subclasses MovieItem and ImageItem Need to import movie library. TWO STEPS. Enjoy sharing of code for 3 types of items.

8 Videos in Processing The fact that Processing is built on (in) Java becomes visible. In next statement, this is a reference to the Papplet that contains all the code. myMovie = new Movie(this,"pantsoyoyoy.mov"); Need to define and include a movieEvent function. This is called a callback. // Called every time //a new frame is available to read void movieEvent(Movie m) { m.read(); }

9 Video in my Collage sketch
Import the video library, it is part of Processing, but not the core: Use Sketch/Import Library … In code, at top: import processing.video.*; My sketch has a Movie object and a MovieItem object: MovieItem is a class I made. Global variables, code in setup, code in class definition.

10 Function, class, method Functions: Classes:
setup, draw, mouseClicked, mousePressed, mouseDragged,mouseReleased,keyPressed,movieEvent overWhich, swapThem, removeFromItemsArray Classes: Item, methods: Item, isOver, removeIt, display, move, duplicate, restart (this is empty in Item) MovieItem, methods: MovieItem, removeIt, duplicate, display, restart ImageItem, methods: ImageItem, duplicate, display

11 Note (and appreciate) The isOver and move methods did not need to be done for the subclasses. The thinking through the design helped even when the subclass required a new method. Making such a list is standard part of planning AND documentation. Alternate is calling and called by table.

12 Examine code Use list Think about how to add other item types.

13 Classwork / Homework Finish and post your virtual something.
Extra credit: research and make posting on compile versus interpreted languages. Don't just copy. Make sure you understand it.


Download ppt "Time to upload Virtual something."

Similar presentations


Ads by Google