Beispiel #1
0
 /** Fires weapons when left mouse is pressed */
 public void mousePressed(MouseEvent evt) {
   int mx = evt.getX(); // x-coordinate where user clicked.
   int my = evt.getY(); // y-coordinate where user clicked.
   if (!pause) {
     if (!evt.isMetaDown()) {
       if (weapons[guntrack].equals("gun") && bshoot) {
         weaponList.add(
             new Bullet(
                 mx, my, character.getX(), character.getY(), 0, THA.WIDTH, 0, THA.HEIGHT, 7));
         bshoot = false;
         ammo.useBullet();
         bulletTime.restart();
       }
       if (weapons[guntrack].equals("grenade") && gshoot) {
         weaponList.add(
             new Grenade(
                 mx, my, character.getX(), character.getY(), 0, THA.WIDTH, 0, THA.HEIGHT, 12));
         gshoot = false;
         ammo.useGrenade();
         grenadeTime.restart();
       }
       if (weapons[guntrack].equals("laser") && lshoot) {
         weaponList.add(
             new Laser(
                 mx, my, character.getX(), character.getY(), 0, THA.WIDTH, 0, THA.HEIGHT, 20));
         lshoot = false;
         ammo.useLaser();
         laserTime.restart();
       }
       if (weapons[guntrack].equals("shotgun") && sgshoot) {
         weaponList.add(
             new ShotGun(
                 mx,
                 my,
                 character.getX(),
                 character.getY(),
                 0,
                 THA.WIDTH,
                 0,
                 THA.HEIGHT,
                 7,
                 character.getX(),
                 character.getY(),
                 25,
                 90,
                 weaponList));
         sgshoot = false;
         ammo.useShotgun();
         shotgunTime.restart();
       }
     }
   }
 }