import javax.swing.*; import java.awt.*; import java.awt.event.*; public class World extends JPanel implements KeyListener, ActionListener { Timer timer; Shape[] shapes = new Shape[8]; public World(Game parent) { parent.addKeyListener(this); timer = new Timer(400, this); // this.shape = new TShape(this); shapes[0] = new LineShape(this); shapes[0].curX = 1; shapes[0].curY = 6; shapes[1] = new LShape(this); shapes[1].curX = 2; shapes[1].curY = 14; shapes[2] = new MirroredLShape(this); shapes[2].curX = 3; shapes[2].curY = 9; shapes[3] = new NoShape(this); shapes[3].curX = 4; shapes[3].curY = 20; shapes[4] = new SquareShape(this); shapes[4].curX = 5; shapes[4].curY = 7; shapes[5] = new SShape(this); shapes[5].curX = 6; shapes[5].curY = 12; shapes[6] = new ZShape(this); shapes[6].curX = 7; shapes[6].curY = 17; shapes[7] = new TShape(this); shapes[7].curX = 7; shapes[7].curY = 2; } public void keyPressed(KeyEvent e) { System.out.println( "... Key pressed: " + e ); } public void keyReleased(KeyEvent e) { System.out.println( "... Key typed: " + e ); } public void keyTyped(KeyEvent e) { System.out.println( "... Key typed: " + e ); } public void start() { // this.timer.start(); } public void actionPerformed(ActionEvent e) { System.out.println( e ); } Shape shape; public void paintComponent(Graphics g) { for (Shape shape : shapes) shape.draw(g); } int squareWidth() { return (int) getSize().getWidth() / BoardWidth; } int squareHeight() { return (int) getSize().getHeight() / BoardHeight; } final int BoardWidth = 10; final int BoardHeight = 22; }