package pong;

import java.awt.Color;
import java.awt.Graphics2D;
import java.util.Random;

public class Ball {
  private float x, y;
  private float angle;
  private float size;

  private Color color;

  public Ball() {
    Random r = new Random();
    this.angle = (float) (r.nextFloat() * 2 * Math.PI);
    this.size = 13;
    this.x = Screen.WIDTH / 2 - this.size / 2;
    this.y = Screen.HEIGHT / 2 - this.size / 2;
    this.color = Color.WHITE;
  }

  public void draw(Graphics2D g2d) {
    g2d.setColor(color);
    g2d.fillRect(
        (int) this.x,
        (int) this.y,
        (int) this.size,
        (int) this.size);
  }

  public void tick() {

  }
}

@@ -173,16 +173,40 @@
  size;%0A%0A
+  private float speed;%0A%0A
   privat
@@ -220,16 +220,16 @@
  color;%0A
-
 %0A  publi
@@ -344,16 +344,36 @@
 e = 13;%0A
+    this.speed = 2;%0A
     this
@@ -697,15 +697,455 @@
 ick() %7B%0A
+    if (this.x + this.size %3E Screen.WIDTH) %7B%0A      // game over, one point to left%0A    %7D else if (this.x %3C 0) %7B%0A      // game over, one point to right%0A    %7D%0A%0A    if (this.y + this.size %3E Screen.HEIGHT %7C%7C this.y %3C 0) %7B%0A      this.angle = (float) (Math.PI - this.angle);%0A    %7D%0A%0A    float d = this.speed;%0A    float dx = (float) (d * Math.sin(this.angle));%0A    float dy = (float) (d * Math.cos(this.angle));%0A%0A    this.x += dx;%0A    this.y += dy;
 %0A  %7D%0A%7D%0A

Make ball bounce off ceiling and floor