in enemy bullet class i am creating two different kind of bullets. 'animationFire' and animationFire2.
Enemy Bullet class

public void paint(Graphics g) 
    {   
        g.drawImage(animationFire.getSprite(), (int)(x),(int)(y), width, height, null); 

        g.drawImage(animationFire2.getSprite(), (int)(x),(int)(y-30), width, height, null); 
        g.drawImage(animationFire2.getSprite(), (int)(x),(int)(y+35), width, height, null);
    }

In Enemy Class i am shooting the bullets. i am doing this by creating bullet and storing in arraylist.
i also have a counter1 so than enemy shoots a bullet than wait lil while than shoot again. and so on...
so counter1 is the time between when enemy shoots bullets.
Enemy Class

...counter1 = 100; ...
    public void enemyBossShootBullet(EnemyBullet enemyBullet, ArrayList<EnemyBullet> enemyBulletStore)
        {
            this.counter1--;                           //dec counter by 1          
            if(this.counter1 <= 0 && !this.shooting)   //when it reach 0 than create bullet
            {
                enemyBullet = new EnemyBullet(x, y+(height/2)-10);  //create enemy bullet
                enemyBulletStore.add(enemyBullet);               //store in arraylist

                this.shooting = true;                         //dont come in this statment if stooting is false 
                this.counter1 = 100;                          //dont come in this statment if counter1 is 0
            }

            if(this.counter1 != 0)                          //if counter is not 0 than set shooting to false   
            {
                this.shooting= false;
            }
        }

right now what happens is that enemy shoots 3 bullet and time between bullets shoot is same.(which is counter1). any idea how can i do it so that time between bullet1 is more. and time between bullet2,3 is less.
ex counter1 = 100; for bullet1 so that there is more time between.
counter2 = 30; for bullet2,3 so that there is less time between.

Recommended Answers

All 2 Replies

Around line 8 you know how many bullets there are in enemyBulletStore, so maybe you could use that to pick a counter value for the next bullet.

when i call this line:
enemyBullet = new EnemyBullet(x, y+(height/2)-10);

it create 3 bullets on screen. if i set up counter wont that use on all those 3 bullets. i was hoping to use on just one bullet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.