float willo_speed;
int willo_color;
- std::auto_ptr<Sprite> glow_sprite;
+ SpritePtr glow_sprite;
Timer colorchange_timer;
Timer suck_timer;
Timer root_timer;
private:
MyState mystate;
- std::auto_ptr<Sprite> base_sprite;
+ SpritePtr base_sprite;
float offset_y;
Timer hatch_timer;
};
static const float EPSILON = .0001f;
static const float BUMP_ROTATION_ANGLE = 10;
-Block::Block(std::auto_ptr<Sprite> newsprite) :
+Block::Block(SpritePtr newsprite) :
sprite(newsprite),
bouncing(false),
breaking(false),
#include <memory>
+#include "sprite/sprite_ptr.hpp"
#include "supertux/moving_object.hpp"
#include "util/reader_fwd.hpp"
-class Sprite;
class Player;
class Block : public MovingObject
{
public:
- Block(std::auto_ptr<Sprite> sprite);
+ Block(SpritePtr sprite);
~Block();
virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
void start_break(GameObject* hitter);
void break_me();
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
bool bouncing;
bool breaking;
float bounce_dir;
{
Sector* sector = Sector::current();
sector->add_object(
- new BrokenBrick(std::auto_ptr<Sprite>(new Sprite(*sprite)), get_pos(), Vector(-100, -400)));
+ new BrokenBrick(sprite->clone(), get_pos(), Vector(-100, -400)));
sector->add_object(
- new BrokenBrick(std::auto_ptr<Sprite>(new Sprite(*sprite)), get_pos() + Vector(0, 16),
+ new BrokenBrick(sprite->clone(), get_pos() + Vector(0, 16),
Vector(-150, -300)));
sector->add_object(
- new BrokenBrick(std::auto_ptr<Sprite>(new Sprite(*sprite)), get_pos() + Vector(16, 0),
+ new BrokenBrick(sprite->clone(), get_pos() + Vector(16, 0),
Vector(100, -400)));
sector->add_object(
- new BrokenBrick(std::auto_ptr<Sprite>(new Sprite(*sprite)), get_pos() + Vector(16, 16),
+ new BrokenBrick(sprite->clone(), get_pos() + Vector(16, 16),
Vector(150, -300)));
remove_me();
}
#include <memory>
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
#include "supertux/timer.hpp"
#include "video/color.hpp"
virtual void draw(DrawingContext& context);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Vector position;
Timer timer;
float emerge_distance;
#include "math/random_generator.hpp"
#include "sprite/sprite.hpp"
-BrokenBrick::BrokenBrick(std::auto_ptr<Sprite> sprite,
+BrokenBrick::BrokenBrick(SpritePtr sprite,
const Vector& pos, const Vector& nmovement) :
timer(),
sprite(sprite),
#include <memory>
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
#include "supertux/timer.hpp"
#include "video/color.hpp"
-class Sprite;
-
class BrokenBrick : public GameObject
{
public:
- BrokenBrick(std::auto_ptr<Sprite> sprite, const Vector& pos, const Vector& movement);
+ BrokenBrick(SpritePtr sprite, const Vector& pos, const Vector& movement);
~BrokenBrick();
virtual void update(float elapsed_time);
private:
Timer timer;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Vector position;
Vector movement;
private:
Physic physic;
int life_count;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
BonusType type;
};
private:
Physic physic;
Vector pos;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
};
#endif
#define HEADER_SUPERTUX_OBJECT_FLOATING_IMAGE_HPP
#include "object/anchor_point.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
-#include <memory>
class Sprite;
void draw(DrawingContext& context);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
int layer;
bool visible;
AnchorPoint anchor;
private:
BonusType type;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
private:
Flower(const Flower&);
private:
Color lightcolor;
- std::auto_ptr<Sprite> lightsprite;
+ SpritePtr lightsprite;
void updateColor();
private:
#include <memory>
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
#include "video/color.hpp"
-class Sprite;
-
class Light : public GameObject
{
public:
protected:
Vector position;
Color color;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
};
#endif
sprite(),
layer(other.layer)
{
- sprite.reset(new Sprite(*other.sprite));
+ sprite = other.sprite->clone();
}
/*
MovingSprite&
#include "supertux/moving_object.hpp"
#include "util/reader_fwd.hpp"
#include "video/drawing_request.hpp"
-
-class Sprite;
+#include "sprite/sprite_ptr.hpp"
/**
* Abstract base class for MovingObjects that are represented by a Sprite
protected:
std::string sprite_name;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
int layer; /**< Sprite's z-position. Refer to video/drawing_context.hpp for sensible values. */
/** set new action for sprite and resize bounding box. use with
#define HEADER_SUPERTUX_OBJECT_PLAYER_HPP
#include "scripting/player.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/direction.hpp"
#include "supertux/moving_object.hpp"
#include "supertux/physic.hpp"
class Climbable;
class Controller;
class CodeController;
-class Sprite;
class Surface;
class Timer;
Portable* grabbed_object;
- std::auto_ptr<Sprite> sprite; /**< The main sprite representing Tux */
+ SpritePtr sprite; /**< The main sprite representing Tux */
SurfacePtr airarrow; /**< arrow indicating Tux' position when he's above the camera */
virtual void draw(DrawingContext& context);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Vector position;
int frame;
};
#ifndef HEADER_SUPERTUX_OBJECT_SMOKE_CLOUD_HPP
#define HEADER_SUPERTUX_OBJECT_SMOKE_CLOUD_HPP
-#include <memory>
-
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
#include "supertux/timer.hpp"
#include "video/color.hpp"
virtual void draw(DrawingContext& context);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Timer timer;
Vector position;
#include "util/reader_fwd.hpp"
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
#include "video/color.hpp"
-class Sprite;
-
class Spotlight : public GameObject
{
public:
private:
Vector position;
float angle;
- std::auto_ptr<Sprite> center;
- std::auto_ptr<Sprite> base;
- std::auto_ptr<Sprite> lights;
- std::auto_ptr<Sprite> light;
- std::auto_ptr<Sprite> lightcone;
+ SpritePtr center;
+ SpritePtr base;
+ SpritePtr lights;
+ SpritePtr light;
+ SpritePtr lightcone;
Color color;
};
virtual void draw(DrawingContext& context);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Vector position;
Vector velocity;
Vector acceleration;
{
}
+SpritePtr
+Sprite::clone() const
+{
+ return SpritePtr(new Sprite(*this));
+}
+
void
Sprite::set_action(const std::string& name, int loops)
{
#define HEADER_SUPERTUX_SPRITE_SPRITE_HPP
#include "sprite/sprite_data.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "video/drawing_context.hpp"
class Surface;
{
public:
Sprite(SpriteData& data);
- Sprite(const Sprite& other);
~Sprite();
+ SpritePtr clone() const;
+
/** Draw sprite, automatically calculates next frame */
void draw(DrawingContext& context, const Vector& pos, int layer);
SpriteData::Action* action;
private:
+ Sprite(const Sprite& other);
Sprite& operator=(const Sprite&);
};
}
}
-std::auto_ptr<Sprite>
+SpritePtr
SpriteManager::create(const std::string& name)
{
Sprites::iterator i = sprites.find(name);
data = i->second;
}
- return std::auto_ptr<Sprite>(new Sprite(*data));
+ return SpritePtr(new Sprite(*data));
}
SpriteData*
#include <memory>
#include <string>
+#include "sprite/sprite_ptr.hpp"
+
class SpriteData;
-class Sprite;
class SpriteManager
{
~SpriteManager();
/** loads a sprite. */
- std::auto_ptr<Sprite> create(const std::string& filename);
+ SpritePtr create(const std::string& filename);
private:
SpriteData* load(const std::string& filename);
--- /dev/null
+// SuperTux
+// Copyright (C) 2009 Ingo Ruhnke <grumbel@gmx.de>
+//
+// 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
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef HEADER_SUPERTUX_SPRITE_SPRITE_PTR_HPP
+#define HEADER_SUPERTUX_SPRITE_SPRITE_PTR_HPP
+
+#include <boost/shared_ptr.hpp>
+
+class Sprite;
+
+typedef boost::shared_ptr<Sprite> SpritePtr;
+
+#endif
+
+/* EOF */
private:
const Level* level; /**< The level of which this is the intro screen */
const Statistics* best_level_statistics; /**< Best level statistics of the level of which is the intro screen */
- std::auto_ptr<Sprite> player_sprite; /**< Sprite representing the player */
+ SpritePtr player_sprite; /**< Sprite representing the player */
float player_sprite_py; /**< Position (y axis) for the player sprite */
float player_sprite_vy; /**< Velocity (y axis) for the player sprite */
Timer player_sprite_jump_timer; /**< When timer fires, the player sprite will "jump" */
DoorState state; /**< current state of the door */
std::string target_sector; /**< target sector to teleport to */
std::string target_spawnpoint; /**< target spawnpoint to teleport to */
- std::auto_ptr<Sprite> sprite; /**< "door" sprite to render */
+ SpritePtr sprite; /**< "door" sprite to render */
Timer stay_open_timer; /**< time until door will close again */
};
private:
std::string sprite_name;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
std::string script;
SwitchState state;
};
#include <list>
#include <memory>
+#include "sprite/sprite_ptr.hpp"
#include "supertux/moving_object.hpp"
#include "supertux/object_remove_listener.hpp"
class Player;
-class Sprite;
/** This class is the base class for all objects you can interact with in some
* way. There are several interaction types defined like touch and activate
virtual void object_removed(GameObject* object);
private:
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
bool lasthit;
bool hit;
bool solved;
bool auto_play; /**< true if Tux should automatically enter this level if it's unfinished */
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
/** Statistics for level tiles */
Statistics statistics;
#include <memory>
#include <string>
-#include "util/reader_fwd.hpp"
#include "math/vector.hpp"
+#include "sprite/sprite_ptr.hpp"
#include "supertux/game_object.hpp"
-
-class Sprite;
+#include "util/reader_fwd.hpp"
namespace worldmap {
Vector pos;
/** Sprite to render instead of guessing what image to draw */
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
/** Message to show in the Map */
std::string map_message;
bool change_on_touch;
/** sprite to change tux image to */
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
/** stay action can be used for objects like boats or cars, if it is
!= "" then this sprite will be displayed when tux left the tile
Vector pos;
/** Sprite to render, or 0 for no sprite */
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
/** Worldmap filename (relative to data root) to teleport to. Leave empty to use current word */
std::string worldmap;
SpriteChange* sprite_change = worldmap->at_sprite_change(tile_pos);
if(sprite_change != NULL) {
- sprite.reset(new Sprite( *(sprite_change->sprite.get()) ));
+ sprite = sprite_change->sprite->clone();
sprite_change->clear_stay_action();
}
SpriteChange* next_sprite = worldmap->at_sprite_change(next_tile);
if(next_sprite != NULL && next_sprite->change_on_touch) {
- sprite.reset(new Sprite( *(next_sprite->sprite.get()) ));
+ sprite = next_sprite->sprite->clone();
next_sprite->clear_stay_action();
}
SpriteChange* last_sprite = worldmap->at_sprite_change(tile_pos);
// check if we already touch a SpriteChange object
SpriteChange* sprite_change = worldmap->at_sprite_change(tile_pos);
if(sprite_change != NULL) {
- sprite.reset(new Sprite( *(sprite_change->sprite.get()) ));
+ sprite = sprite_change->sprite->clone();
sprite_change->clear_stay_action();
}
}
Direction back_direction;
private:
WorldMap* worldmap;
- std::auto_ptr<Sprite> sprite;
+ SpritePtr sprite;
Controller* controller;
Direction input_direction;