package game.space;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;

import game.invader.Invader;

public class SpacePanel extends JPanel implements ActionListener {

    public static final int TIMER_DELAY = 1000;

    protected Timer timer = new Timer(TIMER_DELAY, this);

    protected ArrayList<Invader> invaders = new ArrayList<Invader>();

    LayoutManager layout = new BorderLayout();

    public SpacePanel() {
        setLayout(layout);
    }

    public void addInvader(Invader newInvader) {
        invaders.add(newInvader);
        setLayout(layout);
        add(newInvader);
        revalidate();
        repaint();
    }

    public void moveInvaders() {
        for (Invader invader : invaders) {
            invader.moveDown();
            if (invader.getY() > HEIGHT) {
                invaders.remove(invader);
            }
        }
    }

    public void startTimer() {
        timer.start();
    }

    public void actionPerformed(ActionEvent event) {
        moveInvaders();
        addInvader(Invader.createInvader());
    }
}

@@ -107,16 +107,41 @@
 rayList;
+%0Aimport java.util.Random;
 %0A%0Aimport
@@ -276,18 +276,16 @@
 LAY = 10
-00
 ;%0A%0A    p
@@ -417,102 +417,187 @@
     
-LayoutManager layout = new BorderLayout();%0A%0A    public SpacePanel() %7B%0A        setLayout(layout
+private int totalMomentsCount = 0;%0A%0A    public SpacePanel() %7B%0A        setFocusable(true);%0A        setBackground(Color.BLACK);%0A        setDoubleBuffered(true);%0A        timer.start(
 );%0A 
@@ -689,35 +689,8 @@
 r);%0A
-        setLayout(layout);%0A
     
@@ -862,12 +862,8 @@
 move
-Down
 ();%0A
@@ -874,82 +874,91 @@
     
+%7D%0A
     
-if (invader.getY() %3E HEIGHT) %7B%0A                invaders.re
+%7D%0A%0A    public void actionPerformed(ActionEvent event) %7B%0A        
 move
-(i
+I
 nvader
+s(
 );%0A 
@@ -968,169 +968,167 @@
     
-    %7D%0A        %7D%0A    %7D%0A%0A    public void startTimer() %7B%0A        timer.start(
+totalMomentsCount++;%0A        Random rand = new Random();%0A        int chance = rand.nextInt(100
 );%0A    
-%7D%0A%0A
     
-public void actionPerformed(ActionEvent event) %7B%0A        moveInvaders();%0A
+if (totalMomentsCount %25 30 == 0 && chance %3C 80) %7B%0A    
     
@@ -1146,31 +1146,50 @@
 der(
+new 
 Invader
-.createInvader()
+());%0A        %7D%0A        repaint(
 );%0A 

Improve SpacePanel