Skip to main content
deleted 12 characters in body
Source Link
House
  • 73.5k
  • 17
  • 188
  • 276

Adding a short delay between bullets - slick2d

I'm having some trouble simulating bullets in my 2d2D shooter. I want similar mechanics to megamanMegaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping.

![Bullets being fired][1] [1]: https://i.sstatic.net/eb5k8.png

Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem, thanks.Bullets being fired

In my update method I have the following:

        if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){
                bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() +  17));  
        }

Then I simply iterate through the array list increasing its x value on each update.

Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem?

Adding a short delay between bullets - slick2d

I'm having some trouble simulating bullets in my 2d shooter. I want similar mechanics to megaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping.

![Bullets being fired][1] [1]: https://i.sstatic.net/eb5k8.png

Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem, thanks.

In my update method I have the following:

        if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){
                bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() +  17));  
        }

Then I simply iterate through the array list increasing its x value on each update.

Adding a short delay between bullets

I'm having some trouble simulating bullets in my 2D shooter. I want similar mechanics to Megaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping.

Bullets being fired

In my update method I have the following:

if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){
    bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() +  17));  
}

Then I simply iterate through the array list increasing its x value on each update.

Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem?

Source Link
Sun
  • 367
  • 4
  • 13

Adding a short delay between bullets - slick2d

I'm having some trouble simulating bullets in my 2d shooter. I want similar mechanics to megaman, where the user can hold down the shoot button and a continues stream of bullets are fired but with a slight delay. Currently, when the user fires a bullet in my game a get an almost laser like effect. Below is a screen shot of some bullets being fired while running and jumping.

![Bullets being fired][1] [1]: https://i.sstatic.net/eb5k8.png

Moreover, pressing the shoot button (Space bar) creates multiple bullets instead of just creating one even though I am adding only one new bullet to my array list. What would be the best way to solve this problem, thanks.

In my update method I have the following:

        if(gc.getInput().isKeyDown(Input.KEY_SPACE) ){
                bullets.add(new Bullet(player.getPos().getX() + 30,player.getPos().getY() +  17));  
        }

Then I simply iterate through the array list increasing its x value on each update.