X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fparticlesystem.cpp;h=ea301d871541eb899214d54c6fbe936ea40dc968;hb=546364c9567ef212ea9276201facf73f5ada696a;hp=88b728841c9faf91f3b26157468f408beb578b86;hpb=03fe5c560a616e7d38a8b1d5d11bfe4675fa8896;p=supertux.git diff --git a/src/particlesystem.cpp b/src/particlesystem.cpp index 88b728841..ea301d871 100644 --- a/src/particlesystem.cpp +++ b/src/particlesystem.cpp @@ -17,20 +17,21 @@ // 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" -#include "camera.h" +#include + +#include "particlesystem.h" +#include "app/globals.h" +#include "utils/lispreader.h" +#include "utils/lispwriter.h" +#include "video/drawing_context.h" ParticleSystem::ParticleSystem() { virtual_width = screen->w; virtual_height = screen->h; + layer = LAYER_BACKGROUND1; } ParticleSystem::~ParticleSystem() @@ -62,7 +63,7 @@ void ParticleSystem::draw(DrawingContext& context) if(pos.x > screen->w) pos.x -= virtual_width; if(pos.y > screen->h) pos.y -= virtual_height; - context.draw_surface(particle->texture, pos, LAYER_BACKGROUND1); + context.draw_surface(particle->texture, pos, layer); } context.pop_transform(); @@ -70,9 +71,9 @@ void ParticleSystem::draw(DrawingContext& context) SnowParticleSystem::SnowParticleSystem() { - 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); + snowimages[0] = new Surface(datadir+"/images/shared/snow0.png", true); + snowimages[1] = new Surface(datadir+"/images/shared/snow1.png", true); + snowimages[2] = new Surface(datadir+"/images/shared/snow2.png", true); virtual_width = screen->w * 2; @@ -87,12 +88,25 @@ SnowParticleSystem::SnowParticleSystem() do { particle->speed = snowsize/60.0 + (float(rand()%10)/300.0); } while(particle->speed < 0.01); - particle->speed *= World::current()->get_level()->gravity; particles.push_back(particle); } } +void +SnowParticleSystem::parse(LispReader& reader) +{ + reader.read_int("layer", layer); +} + +void +SnowParticleSystem::write(LispWriter& writer) +{ + writer.start_list("particles-snow"); + writer.write_int("layer", layer); + writer.end_list("particles-snow"); +} + SnowParticleSystem::~SnowParticleSystem() { for(int i=0;i<3;++i) @@ -114,7 +128,7 @@ void SnowParticleSystem::action(float elapsed_time) CloudParticleSystem::CloudParticleSystem() { - cloudimage = new Surface(datadir + "/images/shared/cloud.png", USE_ALPHA); + cloudimage = new Surface(datadir + "/images/shared/cloud.png", true); virtual_width = 2000.0; @@ -130,6 +144,20 @@ CloudParticleSystem::CloudParticleSystem() } } +void +CloudParticleSystem::parse(LispReader& reader) +{ + reader.read_int("layer", layer); +} + +void +CloudParticleSystem::write(LispWriter& writer) +{ + writer.start_list("particles-clouds"); + writer.write_int("layer", layer); + writer.end_list("particles-clouds"); +} + CloudParticleSystem::~CloudParticleSystem() { delete cloudimage;