Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1.  
  2. class Player {
  3. float xpos;
  4. int ypos;
  5. color paddlecolor = color(50);
  6. Player(int screen_y)
  7. {
  8. xpos=SCREENX/2;
  9. ypos=screen_y;
  10. }
  11. void move(int x)
  12. {
  13. if (x>SCREENX-PADDLEWIDTH) xpos = SCREENX - PADDLEWIDTH;
  14. else xpos = x;
  15. }
  16.  
  17. void moveComputer(int x)
  18. {
  19. if (x>SCREENX)
  20. {
  21. xpos = SCREENX;
  22. } else
  23. {
  24. xpos = round(x);
  25. }
  26. }
  27. void draw()
  28. {
  29. {
  30. fill(paddlecolor);
  31. rect(xpos, ypos, PADDLEWIDTH, PADDLEHEIGHT);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement