Can someone help me with this requirement?
In the drawField(Game) method, call the draw(Game) method on each object in the stars list. Pass "this" to the method.
I don't understand what i have to do.
package com.codegym.games.spaceinvaders;
import com.codegym.engine.cell.*;
import java.util.*;
import com.codegym.games.spaceinvaders.gameobjects.*;
public class SpaceInvadersGame extends Game{
public static final int WIDTH=64;
public static final int HEIGHT=64;
private List<Star> stars;
public void initialize(){
setScreenSize(WIDTH,HEIGHT);
createGame();
}
private void createGame(){
createStars();
drawScene();
}
private void drawScene(){
drawField();
}
private void drawField(){
for (int j=0; j < HEIGHT; j++){
for(int i=0; i < WIDTH; i++){
setCellValueEx(i, j, Color.BLACK,"");
}
}
}
private void drawField(Game game){
for (int i=0; i < stars.size(); i++){
stars.get(i).draw(game);
}
}
private void createStars(){
stars= new ArrayList<Star>();
int x=0;
int y=0;
for(int i=0; i < 8; i++){
stars.add(i, new Star(x,y));
x += 8;
y += 4;
}
}
}