public void moveEnemy() { for (int i = 0; i < enemyList.getSize(); i++) { mover.moveEnemy(gameOver, player, enemyList.getEnemy(i), playerMovePosX, playerMoveNegX); } }
@Override public void paintComponent(Graphics g) { g.setColor(Color.BLACK); g.fillRect(0, 0, this.getWidth(), this.getHeight()); // adds background image if (offScreenImage == null) { offScreenImage = createImage(imageList.getImageBase(0).getWidth(), imageList.getImageBase(0).getHeight()); background = offScreenImage.getGraphics(); } background.clearRect( 0, 0, imageList.getImageBase(0).getWidth(), imageList.getImageBase(0).getHeight() + 1); // draws images for (int i = 0; i < imageList.getSize(); i++) { if (i == 0) { background.drawImage(imageList.getImageBase(i).getImage(), 0, 0, this); } background.drawImage( imageList.getImageBase(i).getImage(), imageList.getImageBase(i).getX(), imageList.getImageBase(i).getY(), this); } // draws enemies for (int i = 0; i < enemyList.getSize(); i++) { if (enemyList.getEnemy(i).getHealth() <= 0) { enemyList.getEnemy(i).setCanCollide(false); // This is a major hack and is really, really, REALLY stupid but it works enemyList.getEnemy(i).setX(-enemyList.getEnemy(i).getWidth()); enemyList.getEnemy(i).setY(-enemyList.getEnemy(i).getHeight()); } else { background.drawImage( enemyList.getEnemyImage(i), enemyList.getEnemy(i).getX(), enemyList.getEnemy(i).getY(), this); } } background.drawImage(player.getImage(), player.getX(), player.getY(), this); // draws projectiles for (int i = 0; i < projectileList.size(); i++) { if (projectileList.get(i).getHit()) { projectileList.get(i).setCanCollide(false); projectileList.remove(i); i--; } else { background.drawImage( projectileList.get(i).getImage(), projectileList.get(i).getX(), projectileList.get(i).getY(), this); } } g.drawImage(offScreenImage, imageList.getBaseX(), imageList.getBaseY(), this); g.setColor(Color.WHITE); g.setFont(new Font("default", Font.BOLD, 16)); g.drawString(player.currentHealth.toString(), this.getWidth() - 40, 20); myHUD.draw(g, this); }