another shooting program

i am helping a friend out and hav a bug.

the way its supposed to work is to move the bullets up if they arent to negative 10 in pixels. if they are, then the plane can use it when the mouse is clicked. when i comment out

if (bulletsPlaced =true)

{

for (int i = 0; i < maxBullets; i++)

bufferGraphics.drawImage(myBullets[i],20,myYPositions[i],6,6,this);

bulletsPlaced =false;

}

then the bug doesnt rlly happen.

but if i dont then it puts one bullet at the tip of the plane and then shoots all the others 20 pixels for the x and the same y as that one bullet and then shoots them all up to the top of the screen then does it over and over and over agian.

how can i get it to wer when i click mor than once it fires mor than one bullet and the bullets move?

import java.applet.*;

import java.awt.*;

import java.awt.event.*;

import java.net.*;

publicclass plane2extends Appletimplements MouseMotionListener, MouseListener

{

int maxBullets = 100;

Image[] myBullets =new Image[maxBullets];

int[] myYPositions =newint[maxBullets];

boolean bulletsPlaced =true;

Graphics bufferGraphics;

Graphics a;

Image offscreen;

Dimension dim;

int curX, curY;

int i;

int xpos;

int ypos;

int xposTwo;

int yposTwo;

Image my_gif;

Image my_gifTwo;

Image bullet;

URL base;

MediaTracker mt;

boolean mouseClick;

Image[] bullets =new Image[10];

int[] xposition =newint[10];

int[] yposition =newint[10];

int count = 0;

Graphics mine;

publicvoid init()

{

dim = getSize();

setBackground(Color.black);

offscreen = createImage(dim.width,dim.height);

bufferGraphics = offscreen.getGraphics();

mt =new MediaTracker(this);

try

{

base = getDocumentBase();

}

catch (Exception e){}

my_gif = getImage(base,"su-27.png");

my_gifTwo = getImage(base,"megaman.jpg");

bullet = getImage(base,"bullet.jpg");

mt.addImage(my_gif,1);

mt.addImage(my_gifTwo,2);

mt.addImage(bullet,3);

int aCount = 4;

for (i = 0; i < maxBullets; i++)

{

myBullets[i] = getImage(base,"bullet.jpg");

mt.addImage(myBullets[i],aCount);

//mine.drawImage(myBullets[i],20,-100,6,6,this);

aCount++;

//break;

myYPositions[i] = -100;

}

try

{

mt.waitForAll();

}

catch (InterruptedException e){}

addMouseMotionListener(this);

addMouseListener(this);

}

publicvoid paint(Graphics g)

{

bufferGraphics.clearRect(0,0,dim.width,dim.width);

bufferGraphics.drawImage(my_gif,xpos-25,ypos,50,70,this);

bufferGraphics.drawImage(my_gifTwo,300,20,50,50,this);

if (bulletsPlaced =true)

{

for (int i = 0; i < maxBullets; i++)

bufferGraphics.drawImage(myBullets[i],20,myYPositions[i],6,6,this);

bulletsPlaced =false;

}

if(mouseClick)

{

//g.setColor(Color.red);

//for(i= yposTwo;i>0;i--)

//{

for(i = 0; i < maxBullets; i++)

{

//yposTwo = yposTwo-5;

//g.fillRect(xposTwo,yposTwo,6,6);

if (myYPositions[i] <= -10)

{

myYPositions[i] = yposTwo;

bufferGraphics.drawImage(myBullets[i],xposTwo,myYPositions[i],6,6,this);

pause(10);

break;

}

}

for (i = 0; i<maxBullets;i++)

{

if (myYPositions[i] > -10)

myYPositions[i] = myYPositions[i]-5;

}

//if(xposTwo>300 && xposTwo<350 && i>20 && i<70)

//{

//i= i-1000;

//}

// break;

//}

repaint();

}

g.drawImage(offscreen,0,0,this);

count = count+1;

}

publicvoid update(Graphics g)

{

paint(g);

}

publicvoid mouseClicked (MouseEvent me)

{

xposTwo = me.getX();

yposTwo = me.getY();

mouseClick =true;

repaint();

}

publicvoid mousePressed (MouseEvent me)

{

//xposTwo = me.getX();

//yposTwo = me.getY();

//mouseClick = true;

//repaint();

}

publicvoid mouseReleased (MouseEvent me)

{

//mouseClick = false;

//repaint();

}

publicvoid mouseEntered (MouseEvent me)

{

}

publicvoid mouseExited (MouseEvent me)

{

}

publicvoid mouseMoved(MouseEvent me)

{

xpos = me.getX();

ypos = me.getY();

repaint();

}

publicvoid mouseDragged(MouseEvent me)// This is works like mouseMoved but only when the mouse is being pressed at the same time.

{// To use this for drawing rectangles like in Paint programs you will have to use mousePressed to remember the first coordinates.

}

publicvoid pause(int time)

{

try

{

Thread.sleep(time);

}

catch (InterruptedException e)

{

}

}

}

[10120 byte] By [stephensk8sa] at [2007-11-27 3:09:43]
# 1
i fixed the bullets on the side by changing it to if(bulletsPlaced == true)but i still hav the problem that i can only get one bullet and it wont move. i want multiple bullets that move.
stephensk8sa at 2007-7-12 3:58:53 > top of Java-index,Other Topics,Java Game Development...
# 2
lol i fixed it. it works fine now. thanx for all the help guys. haha
stephensk8sa at 2007-7-12 3:58:53 > top of Java-index,Other Topics,Java Game Development...