// 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 <iostream>
-#include <math.h>
-#include "globals.h"
-#include "world.h"
-#include "level.h"
-#include "scene.h"
-#include "camera.h"
+#include <cmath>
+
+#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()
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();
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;
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)
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;
}
}
+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;