Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualsednihp

Posted 13 October 2012 - 07:58 AM

The rocket doesn't need to know about it's particles, that code goes in the Game/Level update function. A very simplified example:
[source lang="cpp"]void update(){ rocket.move(); if(rand() % 5 < 1) //create a particle on 20% of the frames   particles.push_back(new Particle( rocket.getX(), rocket.getY() ) );   //or if you want smart pointers instead: particles.push_back(std::make_shared< Particle >(rocket.getX(), rocket.getY())); for(auto particle : particles) {   if( particle.isDead() )    //erase particle code here   else    particle.update(); }}[/source]

#3sednihp

Posted 13 October 2012 - 07:57 AM

The rocket doesn't need to know about it's particles, that code goes in the Game/Level update function. A very simplified example:
[source lang="cpp"]void update(){ rocket.move(); if(rand() % 5 < 1) //create a particle on 20% of the frames   particles.push_back(new Particle( rocket.getX(), rocket.getY() ) );   //or if you want smart pointers instead: particles.push_back(std::make_shared<Particle>(rocket.getX(), rocket.getY())); for(auto particle : particles) {   if( particle.isDead() )    //erase particle code here   else    particle.update(); }}[/source]

#2sednihp

Posted 13 October 2012 - 07:57 AM

The rocket doesn't need to know about it's particles, that code goes in the Game/Level update function. A very simplified example:
[source lang="cpp"]void update(){ rocket.move(); if(rand() % 5 < 1) //create a particle on 20% of the frames   particles.push_back(new Particle( rocket.getX(), rocket.getY() ) );   //or if you want smart pointers instead: particles.push_back(std::make_shared<Particle>(rocket.getX(), rocket.getY())); for(auto particle : particles) {   if( particle.isDead() )    //erase particle code here   else    particle.update(); }}[/source]

#1sednihp

Posted 13 October 2012 - 07:57 AM

The rocket doesn't need to know about it's particles, that code goes in the Game/Level update function. A very simplified example:
[source lang="cpp"]void update(){     rocket.move();          if(rand() % 5 < 1) //create a particle on 20% of the frames          particles.push_back(new Particle( rocket.getX(), rocket.getY() ) );   //or if you want smart pointers instead: particles.push_back(std::make_shared<Particle>(rocket.getX(), rocket.getY()));     for(auto particle : particles)     {          if( particle.isDead() )               //erase particle code here          else               particle.update();     }}[/source]

PARTNERS