Skip to content
Permalink
Browse files

Draw the game graphics and give the window a size.

  • Loading branch information
avh4 committed Oct 20, 2012
1 parent e857b8a commit c06169622d704f8f479d3f46b06ee34d795ac7c1
Showing with 20 additions and 0 deletions.
  1. +20 −0 src/PongGame.java
@@ -1,4 +1,5 @@
import javax.swing.*;
import java.awt.*;

public class PongGame extends JComponent {

@@ -12,4 +13,23 @@ public static void main(String[] args) {
window.setVisible(true);
}

public Dimension getPreferredSize() {
return new Dimension(800, 600);
}

@Override
protected void paintComponent(Graphics g) {
// draw the sky
g.setColor(new Color(178, 223, 224));
g.fillRect(0, 0, 800, 600);

// draw the paddle
g.setColor(new Color(110, 61, 23));
g.fillRect(0, 510, 150, 15);

// draw the ball
g.setColor(new Color(155, 93, 169));
g.fillOval(400, 150, 30, 30);
}

}

0 comments on commit c061696

Please sign in to comment.
You can’t perform that action at this time.