Advertisement
fosterbl

Paddle

Feb 25th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. class Paddle extends Block{
  2.    private int speed;
  3.  
  4.    public Paddle(){
  5.       super(10,10,10,10);
  6.       speed =5;
  7.    }
  8.  
  9.    //add other Paddle constructors
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.    //add accessor method for speed
  24.  
  25.    //add mutator method for speed
  26.  
  27.    //add equals method
  28.  
  29.    //add toString method
  30.    
  31.      
  32.    
  33.  
  34.    public void moveUpAndDisplay(){
  35.       //first, draw over the paddle with white
  36.       //using the inherited display(color col)
  37.       display(color(255));
  38.       //then update the y location
  39.       setY(getY() - speed);
  40.       //then display in new location
  41.       display();
  42.    }
  43.  
  44.    public void moveDownAndDisplay(){
  45.      
  46.         //similar to above
  47.    }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement