-
Notifications
You must be signed in to change notification settings - Fork 0
/
Particle.h
58 lines (50 loc) · 1.96 KB
/
Particle.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
/* Particle.h
*
* Floppyright 2010 Tuna <tuna@supertunaman.com>
*
* A particle system for the Arduino and any given graphic LCD.
*
*/
#ifndef PARTICLE_H
#define PARTICLE_H
#include <stdint.h>
#define MAX_PARTICLES 250 //This is (75) 600 bytes. Think before changing this.
#define SCREEN_WIDTH 160
#define SCREEN_HEIGHT 128
/* The Particle class has four members; x and y coordinates, and then
* x and y velocity. The velocity is a number between -25 and 25, which is
* divided by 5 as an integer to come out to some number between -5 and
* 5. This is so that the particle will actually slow to a halt over a
* longer period of time as the velocity is added to or subtracted from,
* one moveParticles() at a time. */
class Particle {
public:
float pX;
float pY;
uint8_t w;
uint8_t h;
int8_t weight;
float velX;
float velY;
uint16_t color;
uint16_t color2;
int16_t life;
};
class Particles {
public:
Particles();
~Particles();
void moveParticles(int cameraX = 0, int cameraY = 0);
void createExplosion(float x, float y, int num_parts = 8, float xspeed = 1, float yspeed = 1, uint16_t color = 0xFFFF, uint16_t color2 = 0xFFFF, int life = -1);
void createDirectionalExplosion(float x, float y, int num_parts = 8, uint8_t size = 1, uint8_t direction = 0xFF, uint16_t color = 0xFFFF, uint16_t color2 = 0xFFFF, int life = -1);
void createBodyExplosion(float x, float y, int num_parts = 8, uint16_t color = 0xFFFF, uint16_t color2 = 0xFFFF, int life = -1);
void createLandingDust(float x, float y, int num_parts = 8, float xspeed = 1, float yspeed = 1, int life = -1);
int getActiveParticles();
void clearParticles();
Particle particles[MAX_PARTICLES];
private:
void addParticle(Particle *particle);
void delParticle(int index);
int activeParticles;
};
#endif