RapidFireOrb.java
01 /*
02  *
03  * Created: Jun  7 2006
04  *
05  * Copyright (C) 1999-2000 Fabien Sanglard
06  
07  * This program is free software; you can redistribute it and/or
08  * modify it under the terms of the GNU General Public License
09  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 
22 package rtype.entity;
23 
24 import org.lwjgl.opengl.GL11;
25 import org.lwjgl.util.vector.Vector2f;
26 
27 import rtype.Prototyp;
28 
29 public class RapidFireOrb extends Orb
30 {
31   
32   protected static float DEFAULT_DISTANCE_FROM_SHIP_WHEN_FIRING = DEFAULT_DISTANCE_FROM_SHIP + 70;
33   
34   public RapidFireOrb(PlayerShip player)
35   {
36     this.playerShip = player;
37     this.type = PINK_ORB;
38     init();
39     animationSpeed = 20f;
40     chargeAnimationSpeed = 0.9f;
41     setRatio(0.35f);
42     
43   }
44 
45   private float bulletsToFire = 0;
46   private float bulletTimeCounter = 0;
47   private float bulletFireRate = 30;
48   private static final float MAX_BULLETS = 100;
49   private static final float FIRE_RATE_LIMIT = 2;
50   
51   public void fire(float chargePercentage)
52   {
53     this.bulletsToFire = (int)MAX_BULLETS * chargePercentage;
54     distanceFromShipRequested = DEFAULT_DISTANCE_FROM_SHIP_WHEN_FIRING ;
55   }
56 
57   RapidFireBullet bu = null;
58   private static float BULLETS_SPEED = 1000;
59   @Override
60   public void update()
61   {
62     super.update();
63     
64     if (bulletsToFire > )
65     {
66       bulletTimeCounter+= bulletFireRate * tick;
67       if (bulletTimeCounter > FIRE_RATE_LIMIT)
68       {
69         bulletsToFire--;
70         bulletTimeCounter = ;
71         bu = new RapidFireBullet(this.rotation);
72         bu.spawn(this.position,new Vector2f((float)(Math.cos(rotationRadians))*BULLETS_SPEED,(float)(Math.sin(rotationRadians))*BULLETS_SPEED),Prototyp.bullets);
73       }
74       if (bulletsToFire < )
75       {
76         distanceFromShipRequested = DEFAULT_DISTANCE_FROM_SHIP;
77       }
78     }
79   }
80 }