B. RAMAMURTHY Lab1 Discussion
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
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
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); }
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); }
Lets try these out Lets try random command and if else selection statement