Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    @Override
    protected void paintComponent(java.awt.Graphics g) {
        //repaint the Panel
        
        super.paintComponent(g);

        /*
         * For every item in paintList call the function
         * paintMe(java.awt.Graphics)
         */
        if(!this.paintList.isEmpty())
        {
            ListIterator<Enemy> paintListIterator = paintList.listIterator();
            int objCounter = 1;

            while (paintListIterator.hasNext()) {
                Enemy aktObj = paintListIterator.next();
                if (aktObj.enemyImage.y > 590) {
                    this.paintList.remove(objCounter);
                    System.out.println("Removed Enemy!");
                } else {
                    aktObj.paintMe(g);
                    this.objPlayer.paintMe(g);
                }
                if(this.paintList.isEmpty())
                {
                    break;
                }
                objCounter += 1;
            }
        }
    }