Hey guys. I wanted to see if someone could help me here. I have the following piece of code that which displays one asteroid on the screen.
// draw asteroid if(!status.isNewAsteroid()) { // draw the asteroid until it reaches the bottom of the screen if(asteroid.getY() + asteroid.getSpeed() < this.getHeight()) { asteroid.translate(0, asteroid.getSpeed()); // Displays one asteroid on the screen: graphicsMan.drawAsteroid(asteroid, g2d, this); } else { asteroid.setLocation(rand.nextInt(getWidth() - asteroid.width), 0); } }
Image of game running with only one asteroid on the screen:
http://i1226.photobucket.com/albums/...dSpaceHelp.jpg
I want to draw more than one asteroid on the screen at the same time. How do I do this? Do I use an Array List? I think I have to use an Enhanced For loop but I am not too sure.
P.S. The new asteroid obviously can't be just a modification of the current asteroid with modified x and y coordinates. It has to be a brand new asteroid of its own of a class Asteroid which I also have and it has to behave differently from the current asteroid. That is why I want to solve the problem with an array list.
Thank you all very much.