Programming gun fire(bullets)

I'm trying to make a space invadors type of game, and I'm having trouble programming the shooting aspect of the game. I want the ship to be able to shoot as many bullets as the user wants. How would I acompish this is the bullets are ovals
[248 byte] By [avalanche333a] at [2007-9-29 18:34:49]
# 1

There are many ways of doing something like this, but this is what came to my mind first.

-Create and ArrayList ArrayList al = new ArrayList();

-Draw the oval (or whatever) from where your ship shoots the bullet and then create a point for that place Point p = new Point()

-Give the x and y positions of where the bullet is to this Point object

p.x = xPos;

p.y = yPos;

-Add this point to your ArrayList al.add(p);

Play with something like this and you will be able to create an array that has all the points (locations) of your bullets and can change dynamically in size. Then cycle through the ArrayList (with a for loop or something) in your game loop and update/check the positions of the bullets.

Hope this helps

RisseNa at 2007-7-15 18:20:27 > top of Java-index,Other Topics,Java Game Development...