Projektordner für das Team Deutsches Museum (FORUM).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rainParticleSystem.cpp 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "rainParticleSystem.h"
  2. RainParticleSystem::RainParticleSystem(float startSceneX, float sceneSizeX, float sceneSizeY) {
  3. this->startSceneX = startSceneX;
  4. this->sceneSizeX = sceneSizeX;
  5. this->sceneSizeY = sceneSizeY;
  6. maxParticle = 40;
  7. birthCnt = 0;
  8. parAmount = 2;
  9. tornadoStartTime = -1000;
  10. time = 0;
  11. status = -1;
  12. }
  13. //--------------------------------------------------------------
  14. void RainParticleSystem::updateParticleSystem() {
  15. double deltaT = ofGetLastFrameTime();
  16. time += deltaT;
  17. //----------------------------------------------------------
  18. if ((birthCnt >= 0) && (status == -1)) { //Create the particle for the rainparticlesystems
  19. createParticlesForRain();
  20. }
  21. //----------------------------------------------------------//Update particle (Movement)
  22. for (int p = 0; p < particles.size(); p++) { //Movement of particles from bottom to top
  23. particles.at(p)->updateParticle(deltaT, ofVec2f(ofRandom(startSceneX, startSceneX + sceneSizeX), 0),
  24. false, false, false, 0, 0, startSceneX + sceneSizeX, sceneSizeY);
  25. }
  26. }
  27. //--------------------------------------------------------------
  28. void RainParticleSystem::createParticlesForRain()
  29. {
  30. for (int i = 0; i < parAmount; i++) {
  31. particles.push_back(new Particle);
  32. int rgen = ofRandom(startSceneX, startSceneX + sceneSizeX);
  33. particles.back()->setup(ofVec2f(rgen, sceneSizeY), 20);
  34. }
  35. birthCnt = 0;
  36. }
  37. //--------------------------------------------------------------
  38. void RainParticleSystem::drawRainParticleSystem() {
  39. for (int i = 0; i < particles.size(); i++) {
  40. particles.at(i)->draw();
  41. }
  42. }