@Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() instanceof Timer){
            int s = rand.nextInt(aliens.size());
            if (s%3 ==0 && s%5 ==0){
                fireAlien(s);
            }


            if(!reverse) {
                for (int i = 0; i < aliens.size(); i++) {
                    Alien a = aliens.remove(i);
                    int x = a.getX();



                    if (x + xDir + a.getWidth() > GameData.GAME_BOARD_WIDTH*4-a.getWidth()) {
                        xDir = -xDir;
                        reverse = true;
                        aliens.add(i, new Alien(x, a.getY(), a.getWidth(), a.getHeight()));
                        break;
                    }
                    x += xDir;

                    aliens.add(i, new Alien(x, a.getY(), a.getWidth(), a.getHeight()));

                }
            }
            if(reverse){
                for(int i = 0; i < aliens.size(); i++){
                    Alien a = aliens.remove(i);
                    int x = a.getX();


                    if(x + xDir < 0 - a.getWidth()) {
                        xDir = 50;
                        reverse = false;
                        aliens.add(i, new Alien(x, a.getY(), a.getWidth(), a.getHeight()));
                        break;
                    }

                    x += xDir;

                    aliens.add(i, new Alien(x, a.getY(), a.getWidth(), a.getHeight()));

                }
            }

        }

        repaint();
    }