Advertisement
Guest User

Untitled

a guest
Jul 24th, 2012
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. package codeSamples_II;
  2.  
  3. import acm.program.*;
  4. import acm.graphics.*;
  5.  
  6.  
  7. public class PlayBall extends GraphicsProgram {
  8.    
  9.     private static final int DELAY = 50;
  10.     private GOval ball;
  11.     private static final int BALL_RADIUS = 10;
  12.    
  13.     public void run() {
  14.         setup();
  15.         play();
  16.     }
  17.        
  18.     private void setup() {
  19.         GOval ball = new GOval(0,0, BALL_RADIUS*2, BALL_RADIUS*2);
  20.         ball.setFilled(true);
  21.         add(ball);
  22.     }
  23.    
  24.     public void play() {
  25.         while (ball.getY() < 200) {
  26.             ball.move(5, 5);
  27.             pause(DELAY);
  28.         }
  29.     }
  30.    
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement