ParticleSystem(128),
cloudimage()
{
- cloudimage = new Surface("images/objects/particles/cloud.png");
+ cloudimage = Surface::create("images/objects/particles/cloud.png");
virtual_width = 2000.0;
CloudParticle* particle = new CloudParticle;
particle->pos.x = systemRandom.rand(static_cast<int>(virtual_width));
particle->pos.y = systemRandom.rand(static_cast<int>(virtual_height));
- particle->texture = cloudimage;
+ particle->texture = cloudimage.get();
particle->speed = -systemRandom.randf(25.0, 54.0);
particles.push_back(particle);
CloudParticleSystem::~CloudParticleSystem()
{
- delete cloudimage;
}
void CloudParticleSystem::update(float elapsed_time)
#ifndef HEADER_SUPERTUX_OBJECT_CLOUD_PARTICLE_SYTEM_HPP
#define HEADER_SUPERTUX_OBJECT_CLOUD_PARTICLE_SYTEM_HPP
+#include <memory>
+
#include "object/particlesystem.hpp"
class CloudParticleSystem : public ParticleSystem
{}
};
- Surface* cloudimage;
+ std::auto_ptr<Surface> cloudimage;
private:
CloudParticleSystem(const CloudParticleSystem&);
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;
particle->pos.x = systemRandom.rand(int(virtual_width));
particle->pos.y = systemRandom.rand(int(virtual_height));
int cometsize = systemRandom.rand(2);
- particle->texture = cometimages[cometsize];
+ particle->texture = cometimages[cometsize].get();
do {
particle->speed = (cometsize+1)*30 + systemRandom.randf(3.6);
} while(particle->speed < 1);
CometParticleSystem::~CometParticleSystem()
{
- for(int i=0;i<2;++i)
- delete cometimages[i];
}
void CometParticleSystem::update(float elapsed_time)
#ifndef HEADER_SUPERTUX_OBJECT_COMET_PARTICLE_SYSTEM_HPP
#define HEADER_SUPERTUX_OBJECT_COMET_PARTICLE_SYSTEM_HPP
+#include <memory>
+
#include "object/particlesystem_interactive.hpp"
class CometParticleSystem : public ParticleSystem_Interactive
{}
};
- Surface* cometimages[2];
+ std::auto_ptr<Surface> cometimages[2];
private:
CometParticleSystem(const CometParticleSystem&);
// 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;
particle->pos.x = systemRandom.randf(virtual_width);
particle->pos.y = systemRandom.randf(SCREEN_HEIGHT);
int size = systemRandom.rand(2);
- particle->texture = ghosts[size];
+ particle->texture = ghosts[size].get();
particle->speed = systemRandom.randf(std::max(50, (size * 10)), 180 + (size * 10));
particles.push_back(particle);
}
GhostParticleSystem::~GhostParticleSystem()
{
- for(int i=0;i<2;++i)
- delete ghosts[i];
}
void GhostParticleSystem::update(float elapsed_time)
#ifndef HEADER_SUPERTUX_OBJECT_GHOST_PARTICLE_SYSTEM_HPP
#define HEADER_SUPERTUX_OBJECT_GHOST_PARTICLE_SYSTEM_HPP
+#include <memory>
+
#include "object/particlesystem.hpp"
class GhostParticleSystem : public ParticleSystem
{}
};
- Surface* ghosts[2];
+ std::auto_ptr<Surface> ghosts[2];
private:
GhostParticleSystem(const GhostParticleSystem&);
RainParticleSystem::RainParticleSystem()
{
- rainimages[0] = new Surface("images/objects/particles/rain0.png");
- rainimages[1] = new Surface("images/objects/particles/rain1.png");
+ rainimages[0] = Surface::create("images/objects/particles/rain0.png");
+ rainimages[1] = Surface::create("images/objects/particles/rain1.png");
virtual_width = SCREEN_WIDTH * 2;
particle->pos.x = systemRandom.rand(int(virtual_width));
particle->pos.y = systemRandom.rand(int(virtual_height));
int rainsize = systemRandom.rand(2);
- particle->texture = rainimages[rainsize];
+ particle->texture = rainimages[rainsize].get();
do {
particle->speed = (rainsize+1)*45 + systemRandom.randf(3.6);
} while(particle->speed < 1);
RainParticleSystem::~RainParticleSystem()
{
- for(int i=0;i<2;++i)
- delete rainimages[i];
}
void RainParticleSystem::update(float elapsed_time)
#ifndef HEADER_SUPERTUX_OBJECT_RAIN_PARTICLE_SYSTEM_HPP
#define HEADER_SUPERTUX_OBJECT_RAIN_PARTICLE_SYSTEM_HPP
+#include <memory>
+
#include "object/particlesystem_interactive.hpp"
class RainParticleSystem : public ParticleSystem_Interactive
{}
};
- Surface* rainimages[2];
+ std::auto_ptr<Surface> rainimages[2];
private:
RainParticleSystem(const RainParticleSystem&);
try
{
// get the arrow sprites
- arrow_scrollup = new Surface("images/engine/menu/scroll-up.png");
- arrow_scrolldown = new Surface("images/engine/menu/scroll-down.png");
+ arrow_scrollup = Surface::create("images/engine/menu/scroll-up.png");
+ arrow_scrolldown = Surface::create("images/engine/menu/scroll-down.png");
}
catch (std::exception& e)
{
log_warning << "Could not load scrolling images: " << e.what() << std::endl;
- arrow_scrollup = 0;
- arrow_scrolldown = 0;
+ arrow_scrollup.reset();
+ arrow_scrolldown.reset();
}
}
for(std::vector<InfoBoxLine*>::iterator i = lines.begin();
i != lines.end(); i++)
delete *i;
-
- delete arrow_scrollup;
- delete arrow_scrolldown;
}
void
{
// draw the scrolling arrows
- if (arrow_scrollup && firstline > 0)
- context.draw_surface(arrow_scrollup,
+ if (arrow_scrollup.get() && firstline > 0)
+ context.draw_surface(arrow_scrollup.get(),
Vector( x1 + width - arrow_scrollup->get_width(), // top-right corner of box
y1), LAYER_GUI);
- if (arrow_scrolldown && linesLeft && firstline < lines.size()-1)
- context.draw_surface(arrow_scrolldown,
+ if (arrow_scrolldown.get() && linesLeft && firstline < lines.size()-1)
+ context.draw_surface(arrow_scrolldown.get(),
Vector( x1 + width - arrow_scrolldown->get_width(), // bottom-light corner of box
y1 + height - arrow_scrolldown->get_height()),
LAYER_GUI);
#define HEADER_SUPERTUX_SUPERTUX_INFO_BOX_HPP
#include <map>
+#include <memory>
#include <string>
#include <vector>
size_t firstline;
std::vector<InfoBoxLine*> lines;
std::map<std::string, Surface*> images;
- Surface* arrow_scrollup;
- Surface* arrow_scrolldown;
+ std::auto_ptr<Surface> arrow_scrollup;
+ std::auto_ptr<Surface> arrow_scrolldown;
private:
InfoBox(const InfoBox&);
player->set_controller(controller.get());
player->set_speedlimit(230); //MAX_WALK_XM
- frame = std::auto_ptr<Surface>(new Surface("images/engine/menu/frame.png"));
+ frame = Surface::create("images/engine/menu/frame.png");
}
std::string