MrThoe

Variables and Shortcuts

Sep 4th, 2020
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. //GLOBAL VARIABLE --> Can be accessed in ANY function
  2. var x = 0;
  3. var y = 0;
  4.  
  5. function setup() {
  6. createCanvas(400, 600); //(widtgh, height)
  7. x = 100;
  8. y = 50;
  9. }
  10.  
  11. function draw() {
  12. period5Lecture();
  13. }
  14.  
  15. /*This was from Friday 9/4/2020
  16. * Pigs > Cats > Dogs > Birbs
  17. */
  18. function period5Lecture(){
  19. if(mouseIsPressed){
  20. background(0); //WIPES SCREEN
  21. }
  22. ellipse(x, y, 20, 20); //circle
  23.  
  24. // x = x + 2 (x is ASSIGNED (=) <-
  25. x+=2; // Shorthand for x = x + 2;
  26. y++; //Shorthand for x += 1;
  27. rect(mouseX, mouseY, 20, 20);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment