This site requires JavaScript, please enable it in your browser!
Greenfoot back
tkurban
tkurban wrote ...

2014/12/23

Help with Bullet

tkurban tkurban

2014/12/23

#
HI, I need help of making the the soldier shoot multiple bullet at once but in different direction,like the shotgun. Her's my current shooting code.
   public void shoot()
    {
        if(timer > 0)timer--;
        if(timer==0 &&Greenfoot.isKeyDown("space") && bulletCheck == false)
        {
            getWorld().addObject(new Bullet(soldierRotation), getX(), getY());
            timer=60;
            Greenfoot.playSound("Shotgun.wav");

            bulletCheck = true;

        }

        if(!Greenfoot.isKeyDown("space") && bulletCheck == true)
        {
            bulletCheck = false;
            Greenfoot.playSound("shotgunshell.wav");
        }
        
    }
danpost danpost

2014/12/23

#
'multiple bullets': what do you think this implies as far as programming this? If you want to do the same thing several times over, what kind of statement do you think would be required? 'different directions: this would imply some randomness in speed and/or direction; initial locations should probably be randomized somewhat also (or the visual of multiple bullets would not be readily apparent).
You need to login to post a reply.