-
Notifications
You must be signed in to change notification settings - Fork 0
/
Particle.cpp
56 lines (39 loc) · 954 Bytes
/
Particle.cpp
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
//
// Particle.cpp
// BasicParticles
//
// Created by Craig Pickard on 1/18/16.
//
//
#include "Particle.hpp"
#include "cinder/Rand.h"
using namespace ci;
using namespace ci::app;
Particle::Particle()
{
}
Particle::Particle( ci::vec2 location )
{
mAcceleration = ci::vec2( ci::randFloat(-.02,.02), ci::randFloat(-.02,.02));
mVelocity = ci::vec2( ci::randFloat(-2,2) , ci::randFloat(-2,2) );
std::cout << mVelocity << std::endl;
mLocation = location;
}
void Particle::run()
{
update();
display();
}
void Particle::update()
{
mVelocity += mAcceleration;
mLocation += mVelocity;
mAcceleration *= 0;
if (mLocation.x > getWindowWidth() || mLocation.x < 0) mVelocity.x *= -1;
if (mLocation.y > getWindowHeight() || mLocation.y < 0) mVelocity.y *= -1;
}
void Particle::display()
{
gl::color( ColorA8u( 255, 255, 255, 255 ) );
gl::drawSolidEllipse( mLocation, 3.0, 3.0 );
}