X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fparticlesystem.cpp;h=e303838d303873151175ffc51fae41660a347265;hb=daa1d5e06caab3b3903afdd36466614a1ee74acf;hp=b85ac368641623ac7e7e31755f4c5353e1d504e8;hpb=fcfe3b0b082bc60402d5ae3ec94df9838488787d;p=supertux.git diff --git a/src/particlesystem.cpp b/src/particlesystem.cpp index b85ac3686..e303838d3 100644 --- a/src/particlesystem.cpp +++ b/src/particlesystem.cpp @@ -16,11 +16,14 @@ // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #include "particlesystem.h" #include #include #include "globals.h" +#include "world.h" +#include "level.h" #include "scene.h" ParticleSystem::ParticleSystem() @@ -61,15 +64,15 @@ void ParticleSystem::draw(float scrollx, float scrolly, int layer) if(x > screen->w) x -= virtual_width; if(y > screen->h) y -= virtual_height; - texture_draw(particle->texture, x, y); + particle->texture->draw(x, y); } } SnowParticleSystem::SnowParticleSystem() { - texture_load(&snowimages[0], datadir+"/images/shared/snow0.png", USE_ALPHA); - texture_load(&snowimages[1], datadir+"/images/shared/snow1.png", USE_ALPHA); - texture_load(&snowimages[2], datadir+"/images/shared/snow2.png", USE_ALPHA); + snowimages[0] = new Surface(datadir+"/images/shared/snow0.png", USE_ALPHA); + snowimages[1] = new Surface(datadir+"/images/shared/snow1.png", USE_ALPHA); + snowimages[2] = new Surface(datadir+"/images/shared/snow2.png", USE_ALPHA); virtual_width = screen->w * 2; @@ -81,11 +84,11 @@ SnowParticleSystem::SnowParticleSystem() particle->y = rand() % screen->h; particle->layer = i % 2; int snowsize = rand() % 3; - particle->texture = &snowimages[snowsize]; + particle->texture = snowimages[snowsize]; do { particle->speed = snowsize/60.0 + (float(rand()%10)/300.0); } while(particle->speed < 0.01); - particle->speed *= gravity; + particle->speed *= World::current()->get_level()->gravity; particles.push_back(particle); } @@ -93,8 +96,8 @@ SnowParticleSystem::SnowParticleSystem() SnowParticleSystem::~SnowParticleSystem() { - for(int i=0;i<3;++i) - texture_free(&snowimages[i]); + for(int i=0;i<3;++i) + delete snowimages[i]; } void SnowParticleSystem::simulate(float elapsed_time) @@ -112,7 +115,7 @@ void SnowParticleSystem::simulate(float elapsed_time) CloudParticleSystem::CloudParticleSystem() { - texture_load(&cloudimage, datadir + "/images/shared/cloud.png", USE_ALPHA); + cloudimage = new Surface(datadir + "/images/shared/cloud.png", USE_ALPHA); virtual_width = 2000.0; @@ -122,7 +125,7 @@ CloudParticleSystem::CloudParticleSystem() particle->x = rand() % int(virtual_width); particle->y = rand() % int(virtual_height); particle->layer = 0; - particle->texture = &cloudimage; + particle->texture = cloudimage; particle->speed = -float(250 + rand() % 200) / 1000.0; particles.push_back(particle); @@ -131,7 +134,7 @@ CloudParticleSystem::CloudParticleSystem() CloudParticleSystem::~CloudParticleSystem() { - texture_free(&cloudimage); + delete cloudimage; } void CloudParticleSystem::simulate(float elapsed_time)