Wreorder fix
[supertux.git] / src / object / comet_particle_system.cpp
index eb2e377..b9b4754 100644 (file)
@@ -1,5 +1,5 @@
 //  SuperTux
-//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
 //
 //  This program is free software: you can redistribute it and/or modify
 //  it under the terms of the GNU General Public License as published by
@@ -23,8 +23,8 @@
 
 CometParticleSystem::CometParticleSystem()
 {
-  cometimages[0] = new Surface("images/creatures/mr_bomb/exploding-left-0.png");
-  cometimages[1] = new Surface("images/creatures/mr_bomb/exploding-left-0.png");
+  cometimages[0] = Surface::create("images/creatures/mr_bomb/exploding-left-0.png");
+  cometimages[1] = Surface::create("images/creatures/mr_bomb/exploding-left-0.png");
 
   virtual_width = SCREEN_WIDTH * 2;
 
@@ -32,12 +32,12 @@ CometParticleSystem::CometParticleSystem()
   size_t cometcount = 2;
   for(size_t i=0; i<cometcount; ++i) {
     CometParticle* particle = new CometParticle;
-    particle->pos.x = systemRandom.rand(int(virtual_width));
-    particle->pos.y = systemRandom.rand(int(virtual_height));
-    int cometsize = systemRandom.rand(2);
+    particle->pos.x = graphicsRandom.rand(int(virtual_width));
+    particle->pos.y = graphicsRandom.rand(int(virtual_height));
+    int cometsize = graphicsRandom.rand(2);
     particle->texture = cometimages[cometsize];
     do {
-      particle->speed = (cometsize+1)*30 + systemRandom.randf(3.6);
+      particle->speed = (cometsize+1)*30 + graphicsRandom.randf(3.6);
     } while(particle->speed < 1);
     particle->speed *= 10; // gravity
 
@@ -48,13 +48,11 @@ CometParticleSystem::CometParticleSystem()
 void
 CometParticleSystem::parse(const Reader& reader)
 {
-  reader.get("z-pos", z_pos);
+  z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1);
 }
 
 CometParticleSystem::~CometParticleSystem()
 {
-  for(int i=0;i<2;++i)
-    delete cometimages[i];
 }
 
 void CometParticleSystem::update(float elapsed_time)
@@ -75,7 +73,7 @@ void CometParticleSystem::update(float elapsed_time)
       if ((particle->pos.y <= SCREEN_HEIGHT + abs_y) && (col >= 1)) {
         Sector::current()->add_object(new Bomb(particle->pos, LEFT));
       }
-      int new_x = systemRandom.rand(int(virtual_width)) + int(abs_x);
+      int new_x = graphicsRandom.rand(int(virtual_width)) + int(abs_x);
       int new_y = 0;
       //FIXME: Don't move particles over solid tiles
       particle->pos.x = new_x;