1 /*
2  * Copyright (c) 2000 Mark B. Allan. All rights reserved.
3  *
4  * "Chromium B.S.U." is free software; you can redistribute
5  * it and/or use it and/or modify it under the terms of the
6  * "Clarified Artistic License"
7  */
8 #ifndef Explosions_h
9 #define Explosions_h
10 
11 #ifdef HAVE_CONFIG_H
12 #include <chromium-bsu-config.h>
13 #endif
14 
15 #include "compatibility.h"
16 
17 #if defined(HAVE_APPLE_OPENGL_FRAMEWORK) || defined(HAVE_OPENGL_GL_H)
18 #include <OpenGL/gl.h>
19 #else
20 #include <GL/gl.h>
21 #endif
22 
23 class Global;
24 class Explo;
25 
26 //====================================================================
27 class Explosions
28 {
29 public:
30 	enum ExploType {	EnemyDestroyed, EnemyDamage,
31 						EnemyAmmo00, EnemyAmmo01, EnemyAmmo02, EnemyAmmo03, EnemyAmmo04,
32 						HeroDestroyed, HeroDamage,
33 						HeroAmmo00, HeroAmmo01, HeroAmmo02,
34 						HeroShields,
35 						PowerBurst,
36 						AddLife, LoseLife, ScoreLife,
37 						Electric, Glitter,
38 						NumExploTypes };
39 	Explosions();
40 	~Explosions();
41 
42 	Explo	*addExplo(ExploType t, float p[3], int age = 0, float size = 1.0);
43 	Explo	*addElectric(float p[3], float v[3], float clr[4], int age = 0, float size = 1.0);
44 	Explo	*addGlitter(float p[3], float v[3], float clr[4], int age = 0, float size = 1.0);
45 
46 	void	update();
47 	void	drawGL();
48 	void	clear();
49 
50 	void	loadTextures();
51 	void	deleteTextures();
52 
53 private:
54 	Explo	*exploRoot[NumExploTypes];
55 	Explo	*exploPool;
56 	GLuint	tex[NumExploTypes];
57 	float	exploSize[NumExploTypes][2];
58 	float	exploStay[NumExploTypes];
59 	float	exploPause[NumExploTypes][3];	/**< # frames to not allow explosions. [0] = count, [1] = base, [2] = flag */
60 
61 	void	drawExplo(ExploType);
62 	void	drawAmmo(ExploType);
63 	void	drawBurst(ExploType);
64 	void	drawShields(ExploType);
65 	void	drawLife(ExploType);
66 	void	drawElectric(ExploType);
67 	void	drawGlitter(ExploType);
68 
69 	Explo	*getNewExplo();
70 	void 	killExplo(Explo *dead);
71 
72 private:
73 	Global	*game;
74 };
75 
76 //====================================================================
77 class Explo
78 {
79 public:
80 	Explo();
81 	~Explo();
82 
83 	void	init(float p[3], int a = 0, float s = 1.0);
84 	void	init(float p[3], float v[3], float c[4], int a = 0, float s = 1.0);
85 
86 	float	pos[3];
87 	float	vel[3];
88 	float	clr[4];
89 	int		age;
90 	float	size;
91 
92 	Explo *back;
93 	Explo *next;
94 
95 private:
96 	static int exploCount;
97 };
98 
99 #endif // Explosions_h
100