Basically, I am creating a top down shooter in java, and for the bullets there is a bullet object with all the properties and update methods and stuff. I hava decided to use an array list to store the bullets in once the mouse is pressed and an instance of the object has been created. The problem is that I do not know how to identify elements in an array list. Here is a snippet of some of the code when i was using just a simple array:
addMouseListener(new MouseAdapter(){
public void mousePressed(MouseEvent e){
pressedX = e.getX();
pressedY = e.getY();
bullets[bulletCount] = new Bullet(player.x, player.y));
double angle = Math.atan2((pressedY - player.y),(pressedX - player.x));
bullets[bulletCount].dx = Math.cos(angle)*5;
bullets[bulletCount].dy = Math.sin(angle)*5;
bulletCount++;
}
Any help is greatly appreciated! Thanks in advance!