Presentation is loading. Please wait.

Presentation is loading. Please wait.

B. RAMAMURTHY Lab1 Discussion. General Instructions Attend the recitation (s), office hours (s) to get help Read the Lab description Understand what is.

Similar presentations


Presentation on theme: "B. RAMAMURTHY Lab1 Discussion. General Instructions Attend the recitation (s), office hours (s) to get help Read the Lab description Understand what is."— Presentation transcript:

1 B. RAMAMURTHY Lab1 Discussion

2 General Instructions Attend the recitation (s), office hours (s) to get help Read the Lab description Understand what is needed. Collect all the images you need before you start. Design/plan before you start programming Book tells you to write a pseudo code before program… pseudo code is the “plan”  Flowchart is another representation for the plan

3 Lets plan Decide the permanent features and write the setup function + test it Collect/draw/create the images of all the creatures you want on the African Savannah. Write the functions for drawing the creatures on the Savannah You need to place the creatures/animals  You need to how to generate and use random numbers  Use mouseX and mouseY and the functions appropriately You need to know “if..else” /selection statement

4 Placing Images PImage pic; void setup() { size(400,400); pic = loadImage("tulips.jpg"); } void draw() { image(pic, 0,0,130,130); }

5 Random function “random” is a function in Processing that helps to get random numbers random(high) ; random(low, high); randomSeed(0); void draw() { int color = int(random(255)); stroke(r); line(i, 0, i, 100); }

6 Picture Background PImage pic; void setup() { size(512,384); pic = loadImage("tulips.jpg"); } void draw() { background(pic); }

7 Selection/choice.. If.else statement if (expression) { statements } else { statements } Example: if (i < 35) { line(30, i, 80, i); } else { line(20, i, 90, i); }

8 Lets try these out Lets try picture, background; Review if..else and random: you will need these for this lab This problem depends on mouse location indicated by mouseX and MouseY. Imagine your canvas with 4 quadrants. Highlight (/color) the quadrant when the mouse moves into that quadrant.


Download ppt "B. RAMAMURTHY Lab1 Discussion. General Instructions Attend the recitation (s), office hours (s) to get help Read the Lab description Understand what is."

Similar presentations


Ads by Google