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
26 import rtype.Prototyp;
27
28 public abstract class Bonus extends AnimatedEntity
29 {
30 public static final int BONUS_COUNT = 5 ;
31
32 public Bonus(int type)
33 {
34 this.type = type;
35 init();
36 this.animationSpeed = 15;
37 this.setRatio(0.25f);
38 }
39
40 public void draw()
41 {
42 animationCursor += animationSpeed * tick ;
43 animationCursor %= animationTextures.length;
44
45 GL11.glLoadIdentity();
46 GL11.glTranslatef(position.x,position.y,Prototyp.DEFAULT_Z); // Translate Into/Out Of The Screen By z
47
48 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.animationTextures[(int)animationCursor].getTextureId() );
49 GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE_MINUS_SRC_ALPHA);
50 //GL11.glBlendFunc(GL11.GL_SRC_ALPHA,GL11.GL_ONE);
51 GL11.glBegin(GL11.GL_QUADS);
52 {
53 GL11.glTexCoord2f(textureRight,textureUp); //Upper right
54 GL11.glVertex2f(width, -height);
55
56 GL11.glTexCoord2f(textureLeft,textureUp); //Upper left
57 GL11.glVertex2f(-width, -height);
58
59 GL11.glTexCoord2f(textureLeft,textureDown); //Lower left
60 GL11.glVertex2f(-width,height);
61
62 GL11.glTexCoord2f(textureRight,textureDown); // Lower right
63 GL11.glVertex2f(width,height);
64 }
65 GL11.glEnd();
66
67 }
68
69 @Override
70 public void update()
71 {
72 interpolate(position,speed);
73 if (this.position.x - this.width > (Prototyp.SCREEN_WIDTH / 2) || this.position.x + this.width < - (Prototyp.SCREEN_WIDTH / 2))
74 {
75 unSpawn();
76 if (Logger.isLogActivate) Logger.log(this.getClass().getName()+" died");
77 return;
78 }
79 }
80
81 public abstract void boostPlayerShip(PlayerShip ship);
82
83 Implosion imp = null;
84 @Override
85 public boolean collided(Entity entity)
86 {
87 // This bonus should only collid with playerShip
88 this.boostPlayerShip((PlayerShip)entity);
89 imp = new Implosion();
90 imp.spawn(this.position,this.speed,Prototyp.fx);
91 this.unSpawn();
92
93 return true;
94
95 }
96
97
98 }
|