Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // making the paddle only
  2.  
  3. //comments below could be stuff you can say
  4.  
  5. void setup() { //always start your code here
  6. size(400, 400); //creating a "canvas", horizontal 400 x vertical 400
  7. }
  8.  
  9. float paddleX = 20; //the paddle is the thing you move
  10. float paddleY = height-15;
  11.  
  12. void draw() {
  13. background(255, 255, 255); //DONT SHOW THIS YET, AND SHOW WHAT HAPPENS: this line is placed so that it refreshes.
  14. rect(paddleX, paddleY, 30, 10); //review coordinate system, draws a rectangle at coordinates (paddleX, paddleY) to (30, 10)
  15. }
  16.  
  17.  
  18. void mouseMoved() { //so now we create a function called mouseMoved
  19. paddleX = mouseX; //sets the value of the X-coordinate of the paddle, to the X position of the mouse cursor
  20. }
  21.  
  22.  
  23.  
  24.  
  25. /*
  26. recommendations:
  27.  
  28. way to write the code along with them:
  29.  
  30. 1) void setup
  31. 2) void draw with only rect function(use 4 numbers instead of paddleX, paddleY)
  32. 3) explain that you now want to make it move, so you have to use variables as they are changing
  33. 4) create the 2 floats, insert into rect function
  34. 5) do void mouseMoved
  35. 6)show them that for some reason that are trailing shapes
  36. 7) background function (resseting)
  37.  
  38. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement