-
Notifications
You must be signed in to change notification settings - Fork 1
/
ModuleParticles.h
145 lines (124 loc) · 2.74 KB
/
ModuleParticles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef __ModuleParticles_H__
#define __ModuleParticles_H__
#include "Module.h"
#include "Animation.h"
#include "Globals.h"
#include "p2Point.h"
#include "ModulePlayer.h"
#include "ModuleCollision.h"
#include "ModuleEnemies.h"
#include "Path.h"
#define MAX_ACTIVE_PARTICLES 100
#define MAX_PARTICLE_TEXTURES 7
struct SDL_Rect;
struct SDL_Texture;
struct Mix_Chunk;
struct Collider;
enum COLLIDER_TYPE;
enum PARTICLE_TEXTURE
{
PARTICLES_PLAYER,
PARTICLES_LASERS,
POWERUP,
PARTICLES_EXPLOSION,
PARTICLES_ENEMYSHOOT,
STAGE4BOSS_SHOOT,
SENTINEL_SHOOT,
};
enum PARTICLE_TYPE
{
NONE,
BASIC_SHOOT,
TENTACLE_SHOOT,
BASIC_LASER,
BOMB_SHOOT,
BOMB_EXPLOSION,
PLAYER_EXPLOSION,
ENEMY_EXPLOSION,
TENTACLE_EXPLOSION,
BASIC_SHOOT_EXPLOSION,
ANEMONA_SHOOT,
SHRIMP_SHOOT,
MISSILE_SHOOT,
MISSILE_EXPLOSION,
STAGE4BOSS_SHOOTN,
SENTINEL_SHOOTN,
ORB,
ORB_SHOOT,
ORB_EXPLOSION,
};
struct Particle {
Collider* collider = nullptr;
Animation anim;
Mix_Chunk* fx = 0;
Mix_Chunk* hit_fx = 0;
iPoint position;
fPoint speed;
fPoint direction_speed;
Uint32 born = 0;
Uint32 life = 0;
float angle = 0.0f;
bool fx_played = false;
int id = 0;
PARTICLE_TYPE type = NONE;
Path* path = new Path();
Enemy* target = nullptr;
Particle();
Particle(const Particle& p);
~Particle();
bool Update();
bool operator==(const Particle &g) const
{
return this->id == g.id;
}
};
class ModuleParticles : public Module
{
public:
ModuleParticles();
~ModuleParticles();
bool Start();
update_status PostUpdate();
update_status Update();
void Shoot_Orb(Particle * p);
bool CleanUp();
void OnCollision(Collider* c1, Collider* c2);
void removeParticles();
void orderlist();
void swap(iPoint * positions, int i, int j);
void AddParticle(const Particle& particle, int x, int y, COLLIDER_TYPE collider_type = COLLIDER_NONE, fPoint direction_speed = { 0,0 }, Uint32 delay = 0);
void MissilleMovement(Particle* particle);
void EnemyPositions(Particle* particle);
public:
iPoint positions[MAX_ENEMIES];
Uint32 * start_time = 0;
Uint32* shooting_delay;
Particle basic_laser;
Particle basic_shoot;
Particle tentacle_shoot;
Particle missile;
Particle spawn_missile;
Particle orb;
Particle orb_shoot;
Particle bomb;
Particle explosion_player;
Particle explosion_enemy;
Particle explosion_bullet;
Particle explosion_tentacle_bullet;
Particle explosion_bomb;
Particle explosion_missile;
Particle explosion_orb;
Particle anemona_shoot;
Particle shrimp_shoot;
Particle bluesentinelshot;
Particle Stage4Boss_shoot;
Particle Powerup;
Animation* animation = nullptr;
int active_missiles = 0;
int orbs = 0;
private:
SDL_Texture * graphics[MAX_PARTICLE_TEXTURES];
Particle * active[MAX_ACTIVE_PARTICLES];
uint last_particle = 0;
};
#endif // __ModuleInput_H__