Upload del repo clone di twang
This commit is contained in:
parent
9c164ceb04
commit
a20252c357
13 changed files with 1873 additions and 0 deletions
59
Particle.h
Normal file
59
Particle.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "Arduino.h"
|
||||
#define FRICTION 1
|
||||
|
||||
class Particle
|
||||
{
|
||||
public:
|
||||
void Spawn(int pos);
|
||||
void Tick(int USE_GRAVITY);
|
||||
void Kill();
|
||||
bool Alive();
|
||||
int _pos;
|
||||
int _power;
|
||||
private:
|
||||
int _life;
|
||||
int _alive;
|
||||
int _sp;
|
||||
};
|
||||
|
||||
void Particle::Spawn(int pos){
|
||||
_pos = pos;
|
||||
_sp = random(-200, 200);
|
||||
_power = 255;
|
||||
_alive = 1;
|
||||
_life = 220 - abs(_sp);
|
||||
}
|
||||
|
||||
void Particle::Tick(int USE_GRAVITY){
|
||||
if(_alive){
|
||||
_life ++;
|
||||
if(_sp > 0){
|
||||
_sp -= _life/10;
|
||||
}else{
|
||||
_sp += _life/10;
|
||||
}
|
||||
if(USE_GRAVITY && _pos > 500) _sp -= 10;
|
||||
_power = 100 - _life;
|
||||
if(_power <= 0){
|
||||
Kill();
|
||||
}else{
|
||||
_pos += _sp/7.0;
|
||||
if(_pos > 1000){
|
||||
_pos = 1000;
|
||||
_sp = 0-(_sp/2);
|
||||
}
|
||||
else if(_pos < 0){
|
||||
_pos = 0;
|
||||
_sp = 0-(_sp/2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Particle::Alive(){
|
||||
return _alive;
|
||||
}
|
||||
|
||||
void Particle::Kill(){
|
||||
_alive = 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue