Presentation is loading. Please wait.

Presentation is loading. Please wait.

Animation Pages 133-141.

Similar presentations


Presentation on theme: "Animation Pages 133-141."— Presentation transcript:

1 Animation Pages

2 Function Function Definition Calling a function Parameters
Return type and return statement

3 Function: Intuitive Understanding
Function F F(x) X

4 Examples Add 10 20 10 X=10, y=4 Multiply (x,y) 40 Subtract 6 4

5 Function concept int z = add(34, 10); // function call
Function definition: int add (int x , int y) // x,y formal parameters { int sum;// sum is a local variable sum = x + y; return sum; } add 34 10 X Y sum

6 translate Translate function moves the origin by the amount specified int x,y; x = 10; y = 10; void draw() { background(30,50,60); translate(x,y); rect(x,y,70,30); x++; if (x> width) x = 0; y++; if (y>height) y = 0; }

7 Multiple objects Consider a scenario with multiple objects
Each with its own initial position Size Speed How will you define these? How will control these? How will you detect collisions among these and take action?

8 Matrices (or layers) In order to represent independent motion and axes and other attributes, Processing provides pushMatrix() and popMatrix() These create new layers of axes for objects to exist and be controlled independently. Lets look at some examples.


Download ppt "Animation Pages 133-141."

Similar presentations


Ads by Google