rendered paste body/*
* GameArea.java
*
* Skapad den 7 februari 2007, 14:39
*/
package jezzball;
import javax.swing.*;
import java.awt.*;
import java.util.Random;
/**
*
* @author root
*/
public class GameArea extends JPanel implements Runnable {
private java.util.List<GameObject> gameObjects;
private int width, height;
private Ball [] balls = new Ball[5];
private Random random = new Random();
public java.util.List<GameObject> getGameObjects() {
return gameObjects;
}
public GameArea(int width, int height) {
this.width = width;
this.height = height;
setPreferredSize(new Dimension(width,height));
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < balls.length; i ++) {
balls[i].move(height,width);
balls[i].draw(g);
}
}
public void run() {
for (int i = 0; i < balls.length; i ++) {
balls[i] = new Ball(width/2,height/2,10,Color.red);
balls[i].setX(random.nextInt(balls.length));
balls[i].setK(random.nextDouble() * random.nextInt(balls.length));
}
while(true) {
try {
Thread.sleep(20);
} catch(InterruptedException ie) {}
repaint();
}
}
}