breakout 1972 1976 over 10 000 students due in week 5 of
play

Breakout 1972 1976 Over 10,000 students Due in week 5 of CS106A - PowerPoint PPT Presentation

Breakout 1972 1976 Over 10,000 students Due in week 5 of CS106A Big program. Do it in parts 1 2 3 getCollidingObject 4 GObject collider = getElementAt( x , y ); , , a brick null Pro Tips v Want to wait for a click to start? Use


  1. Breakout

  2. 1972 1976

  3. Over 10,000 students Due in week 5 of CS106A

  4. Big program. Do it in parts 1 2 3

  5. getCollidingObject 4 GObject collider = getElementAt( x , y ); , , a brick null

  6. Pro Tips v Want to wait for a click to start? Use waitForClick() v Do not animate in mouse moved ! v Use instance var for paddle. v Make sure to test as you go . Program one milestone at a time. v No instance variable for bricks

  7. How do you know if you hit a brick? 4 GObject collider = getElementAt( x , y ); , , a brick null

  8. Aside: Secret to how memory really works

  9. Who thinks this prints true ? public void run() { int x = 5; int y = 5; println(x == y); }

  10. Who thinks this prints true ?

  11. Who thinks this prints true ?

  12. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; }

  13. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; }

  14. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; } toInches f feet 5

  15. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; } toInches f feet 5 result 60

  16. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; } toInches f feet 5 k c a t s result 60

  17. Stack Diagrams public void run() { run println(toInches(5)); } private int toInches(int feet){ int result = feet * 12; return result; } 60 f

  18. Aside: Actual Memory

  19. What is a bucket feet 5

  20. What is a bucket feet 1011100111100011 0011010110010100 * Each bucket or “word” holds 64 bits ** don’t think on the binary level (yet)

  21. variables have fixed size buckets to store values

  22. Primitives vs Classes Primitive Variable Types Class Variable Types int GRect double GOval char Gline boolean Color Class variables (aka objects) 1. Have upper camel case types 2. You can call methods on them 3. Are constructed using new 4. Are stored in a special way Piech, CS106A, Stanford University

  23. Primitives vs Classes Primitive Variable Types Class Variable Types int GRect aka double GOval Objects char Gline boolean Color Class variables (aka objects) 1. Have upper camel case types 2. You can call methods on them 3. Are constructed using new 4. Are stored in a special way Piech, CS106A, Stanford University

  24. How do you share wikipedia articles? Antelope Canyon Article Key: https://en.wikipedia.org/wiki/Antelope_Canyon Piech, CS106A, Stanford University

  25. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap run Piech, CS106A, Stanford University

  26. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap run Piech, CS106A, Stanford University

  27. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap run Piech, CS106A, Stanford University

  28. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap run Piech, CS106A, Stanford University

  29. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run Piech, CS106A, Stanford University

  30. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run img Piech, CS106A, Stanford University

  31. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run 42 img Piech, CS106A, Stanford University

  32. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run 42 img Piech, CS106A, Stanford University

  33. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run 42 img Piech, CS106A, Stanford University

  34. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 run 42 img Piech, CS106A, Stanford University

  35. public void run() { GImage img = new GImage(”mountain.jpg”); add(img, 0, 0); } stack heap 42 Piech, CS106A, Stanford University

  36. Piech, CS106A, Stanford University

  37. Who thinks this prints true ? Piech, CS106A, Stanford University

  38. Who thinks this prints true ? memory.com/18 Piech, CS106A, Stanford University

  39. Who thinks this prints true ? memory.com/18 Piech, CS106A, Stanford University

  40. Who thinks this prints true ? memory.com/18 instance vars 18 first Piech, CS106A, Stanford University

  41. Who thinks this prints true ? memory.com/18 instance vars 18 first Piech, CS106A, Stanford University

  42. Who thinks this prints true ? memory.com/18 instance vars 18 first run Piech, CS106A, Stanford University

  43. Who thinks this prints true ? memory.com/18 instance vars 18 first run Piech, CS106A, Stanford University

  44. Who thinks this prints true ? memory.com/18 instance vars 18 first run Piech, CS106A, Stanford University

  45. Who thinks this prints true ? memory.com/18 instance vars 18 first run Piech, CS106A, Stanford University

  46. Who thinks this prints true ? memory.com/18 instance vars 18 first run 18 second Piech, CS106A, Stanford University

  47. Who thinks this prints true ? memory.com/18 instance vars 18 first run 18 second Piech, CS106A, Stanford University

Recommend


More recommend