X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Fghost_particle_system.cpp;h=dd2e0477b9518a4b75fe1fc0fa7bde1245db4ef1;hb=b88dc6c0a778a019bf0b1f28c2cc9d624d9bbdbd;hp=4b493a4666dee508e848c83b3956ced8c7be4b4d;hpb=abcb5a66b00aff23c5f1587646f9298fc0a9d8be;p=supertux.git diff --git a/src/object/ghost_particle_system.cpp b/src/object/ghost_particle_system.cpp index 4b493a466..dd2e0477b 100644 --- a/src/object/ghost_particle_system.cpp +++ b/src/object/ghost_particle_system.cpp @@ -1,5 +1,5 @@ // SuperTux -// Copyright (C) 2009 Ingo Ruhnke +// Copyright (C) 2009 Ingo Ruhnke // // 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 @@ -19,15 +19,15 @@ #include #include "math/random_generator.hpp" -#include "supertux/main.hpp" +#include "supertux/globals.hpp" #include "video/drawing_context.hpp" //FIXME: Sometimes both ghosts have the same image // Ghosts don't change their movement pattern - not random GhostParticleSystem::GhostParticleSystem() { - ghosts[0] = new Surface("images/objects/particles/ghost0.png"); - ghosts[1] = new Surface("images/objects/particles/ghost1.png"); + ghosts[0] = Surface::create("images/objects/particles/ghost0.png"); + ghosts[1] = Surface::create("images/objects/particles/ghost1.png"); virtual_width = SCREEN_WIDTH * 2; @@ -35,11 +35,11 @@ GhostParticleSystem::GhostParticleSystem() size_t ghostcount = 2; for(size_t i=0; ipos.x = systemRandom.randf(virtual_width); - particle->pos.y = systemRandom.randf(SCREEN_HEIGHT); - int size = systemRandom.rand(2); + particle->pos.x = graphicsRandom.randf(virtual_width); + particle->pos.y = graphicsRandom.randf(SCREEN_HEIGHT); + int size = graphicsRandom.rand(2); particle->texture = ghosts[size]; - particle->speed = systemRandom.randf(std::max(50, (size * 10)), 180 + (size * 10)); + particle->speed = graphicsRandom.randf(std::max(50, (size * 10)), 180 + (size * 10)); particles.push_back(particle); } } @@ -47,13 +47,11 @@ GhostParticleSystem::GhostParticleSystem() void GhostParticleSystem::parse(const Reader& reader) { - reader.get("z-pos", z_pos); + z_pos = reader_get_layer (reader, /* default = */ LAYER_BACKGROUND1); } GhostParticleSystem::~GhostParticleSystem() { - for(int i=0;i<2;++i) - delete ghosts[i]; } void GhostParticleSystem::update(float elapsed_time) @@ -65,7 +63,7 @@ void GhostParticleSystem::update(float elapsed_time) particle->pos.x -= particle->speed * elapsed_time; if(particle->pos.y > SCREEN_HEIGHT) { particle->pos.y = fmodf(particle->pos.y , virtual_height); - particle->pos.x = systemRandom.rand(static_cast(virtual_width)); + particle->pos.x = graphicsRandom.rand(static_cast(virtual_width)); } } }