1 /*
2   Copyright (C) 2000 Xavier Hosxe <xhosxe@free.fr>
3 
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; either version 2 of the License, or
7   (at your option) any later version.
8 
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   GNU General Public License for more details.
13 
14   You should have received a copy of the GNU General Public License
15   along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19 
20 #ifndef __SPRITE__
21 #define __SPRITE__
22 
23 #ifdef WIN32
24 #include <windows.h>
25 #endif
26 
27 #include <stdio.h>
28 #include <math.h>
29 #include <GL/gl.h>
30 #include <GL/glext.h>
31 #include <GL/glu.h>
32 #include <GL/glut.h>
33 
34 #ifndef WIN32
35 #include "conf.h"
36 #endif
37 
38 #include "variables.hpp"
39 #include "elem.hpp"
40 #include "list.hpp"
41 
42 #define MAX_LISTENING 5
43 
44 enum enum_state {
45     NOT_STARTED=1,
46         NORMAL,
47         UNTOUCHABLE,
48         MOVING,
49         TOUCHING,
50         DEAD
51 } ;
52 
53 class Sprite : public  Elem {
54     friend class ListSprite;
55 public:
56 
57     enum type_sprites {
58         TYPE_MY_SPACE_SHIP=1,
59             TYPE_MY_FIRE1,
60             TYPE_MY_FIRE2,
61             TYPE_MY_FIRE4,
62             TYPE_WALL,
63             TYPE_ENEMY1,
64             TYPE_CUBE,
65             TYPE_EXPLOSION,
66             TYPE_PIECEOFSHIP,
67             TYPE_SHIP1,
68             TYPE_FIRE_SHIP1,
69             TYPE_SPIRALE,
70             TYPE_PIEGE,
71             TYPE_POTO,
72             TYPE_TANK,
73             TYPE_FIRE_TANK,
74             TYPE_SCRATCHER,
75             TYPE_TACHE,
76             TYPE_BANDIT2,
77             TYPE_FIRE_BANDIT2,
78             TYPE_DIAMOND,
79             TYPE_SMOKE,
80             TYPE_UNDEF
81     } ;
82     // Constructor
83     Sprite(List *list);
84     Sprite(List *list, type_sprites type, float x, float y, float z);
85     // Destructor
~Sprite()86     virtual ~Sprite() {}
87     // Methods
88     virtual void draw()=0;
89     virtual void collision(Sprite *)=0;
90     virtual void move();
drawShadowable()91     virtual void drawShadowable() {}
92 
getX()93     virtual float getX() { return x_; }
getY()94     virtual float getY() { return y_; }
getZ()95     virtual float getZ() { return z_; }
getDx()96     float getDx() { return dx_; }
getDy()97     float getDy() { return dy_; }
getDz()98     float getDz() { return dz_; }
getSizeX()99     float getSizeX() { return sizex_; }
getSizeY()100     float getSizeY() { return sizey_; }
getSizeZ()101     float getSizeZ() { return sizez_; }
getType()102     type_sprites getType() { return type_; }
isDead()103     int isDead() {return dead_;}
104 
105 
106     void PlaySample(type_samples sampleToPlay,int volume=128);
107     void SpritePlaySample(type_samples sampleToPlay,int volume=128);
108 
109     bool addListeningSprite(Sprite*toAdd);
110     void removeListeningSprite(Sprite*toRemove);
score(int toAdd)111     virtual void score(int toAdd) {};
112     virtual void iJustDied();
113     virtual void receiveEvent(Sprite*sprite);
114 protected:
115     Sprite *listeningSprite[MAX_LISTENING];
116     int nListeningSprite;
117     type_sprites type_;
118     float x_;
119     float y_;
120     float z_;
121     float dx_;
122     float dy_;
123     float dz_;
124     float sizex_;
125     float sizey_;
126     float sizez_;
127     int dead_;
128     // The following one is true for the
129     // the enemy which can be followed by a missile.
130     bool bRealEnemy;
131 };
132 
133 #endif
134 
135 
136 
137 
138 
139 
140