Blaster.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 Blaster extends Weapon
30 {
31   public Blaster(PlayerShip player)
32   {
33     this.playerShip = player;
34     this.type = FORCE_CHARGE;
35     init();
36     animationSpeed = 28.4f;
37     setRatio(0.55f);
38   
39   }
40   
41   public void draw()
42   {
43     if (this.displayChargeAnimation)
44          {
45       GL11.glColor4f(0,1,1,1f);
46       
47            animationCursor += animationSpeed * tick  ;
48            animationCursor %= animationTextures.length;
49   
50            GL11.glLoadIdentity();            
51       GL11.glTranslatef(playerShip.position.x+width+13,playerShip.position.y+3,Prototyp.DEFAULT_Z);                       
52       GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.animationTextures[(int)animationCursor].getTextureId() );
53       GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);
54       GL11.glBegin(GL11.GL_QUADS);
55       {
56         GL11.glTexCoord2f(textureRight,textureUp)//Upper right
57         GL11.glVertex2f(width, -height);
58         
59         GL11.glTexCoord2f(textureLeft,textureUp)//Upper left      
60         GL11.glVertex2f(-width, -height);        
61        
62         GL11.glTexCoord2f(textureLeft,textureDown)//Lower left
63         GL11.glVertex2f(-width,height);
64           
65         GL11.glTexCoord2f(textureRight,textureDown)// Lower right
66         GL11.glVertex2f(width,height);  
67       }
68            GL11.glEnd();
69            
70         GL11.glColor4f(1f,1f,1f,1f);
71          }
72   }
73 
74   public void startChargingAnimation()
75   {
76     this.displayChargeAnimation = true;
77     
78   }
79 
80   public void stopChargingAnimation()
81   {
82     this.displayChargeAnimation = false;
83     this.animationCursor = 0;
84   }
85 
86   public void fire(float chargePercentage)
87   {
88     ForceBlast fb = new ForceBlast(chargePercentage*1.3f);
89     fb.spawn(playerShip.position,new Vector2f(770,0),Prototyp.bullets);
90     
91     //Prototyp.bullets.add(fb);
92     
93   }
94   
95   
96 }