countMe = false;
sound_manager->preload("sounds/yeti_gna.wav");
sound_manager->preload("sounds/yeti_roar.wav");
- hud_head.reset(new Surface("images/creatures/yeti/hudlife.png"));
+ hud_head = Surface::create("images/creatures/yeti/hudlife.png");
}
Yeti::~Yeti()
effect_progress = 0.0f;
effect_start_time = 0.0f;
- checkbox.reset(new Surface("images/engine/menu/checkbox-unchecked.png"));
- checkbox_checked.reset(new Surface("images/engine/menu/checkbox-checked.png"));
- back.reset(new Surface("images/engine/menu/arrow-back.png"));
- arrow_left.reset(new Surface("images/engine/menu/arrow-left.png"));
- arrow_right.reset(new Surface("images/engine/menu/arrow-right.png"));
+ checkbox = Surface::create("images/engine/menu/checkbox-unchecked.png");
+ checkbox_checked = Surface::create("images/engine/menu/checkbox-checked.png");
+ back = Surface::create("images/engine/menu/arrow-back.png");
+ arrow_left = Surface::create("images/engine/menu/arrow-left.png");
+ arrow_right = Surface::create("images/engine/menu/arrow-right.png");
}
Menu::~Menu()
set_image(imagefile, speed);
reader.get("speed-y", speed_y);
if (reader.get("image-top", imagefile_top)) {
- image_top.reset(new Surface(imagefile_top));
+ image_top = Surface::create(imagefile_top);
}
if (reader.get("image-bottom", imagefile_bottom)) {
- image_bottom.reset(new Surface(imagefile_bottom));
+ image_bottom = Surface::create(imagefile_bottom);
}
}
this->imagefile = name;
this->speed = speed;
- image.reset(new Surface(name));
+ image = Surface::create(name);
}
void
pos = Vector(px, py);
if(!reader.get("image", imagefile)) throw std::runtime_error("Must specify image for decal");
- image.reset(new Surface(imagefile));
+ image = Surface::create(imagefile);
reader.get("layer", layer);
}
reader.get("name", name);
reader.get("time", time_left);
if(time_left <= 0) throw std::runtime_error("No or invalid leveltime specified");
- time_surface.reset(new Surface("images/engine/hud/time-0.png"));
+ time_surface = Surface::create("images/engine/hud/time-0.png");
}
void
controller = g_main_controller;
scripting_controller.reset(new CodeController());
sprite = sprite_manager->create("images/creatures/tux/tux.sprite");
- airarrow.reset(new Surface("images/engine/hud/airarrow.png"));
+ airarrow = Surface::create("images/engine/hud/airarrow.png");
idle_timer.start(IDLE_TIME[0]/1000.0f);
sound_manager->preload("sounds/bigjump.wav");
{
font.reset(new Font(Font::FIXED,"fonts/andale12.stf",1));
fontheight = font->get_height();
- background.reset(new Surface("images/engine/console.png"));
- background2.reset(new Surface("images/engine/console2.png"));
+ background = Surface::create("images/engine/console.png");
+ background2 = Surface::create("images/engine/console2.png");
}
void
game_pause = false;
speed_before_pause = g_screen_manager->get_speed();
- statistics_backdrop.reset(new Surface("images/engine/menu/score-backdrop.png"));
+ statistics_backdrop = Surface::create("images/engine/menu/score-backdrop.png");
restart_level();
font = get_font_by_format_char(format_char);
lineType = get_linetype_by_format_char(format_char);
color = get_color_by_format_char(format_char);
- if (lineType == IMAGE) image = new Surface(text);
+ if (lineType == IMAGE)
+ {
+ image = Surface::create(text);
+ }
}
InfoBoxLine::~InfoBoxLine()
{
- delete image;
}
const std::vector<InfoBoxLine*>
Vector position = bbox.p1;
switch (lineType) {
case IMAGE:
- context.draw_surface(image, Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
+ context.draw_surface(image.get(), Vector( (bbox.p1.x + bbox.p2.x - image->get_width()) / 2, position.y), layer);
break;
case NORMAL_LEFT:
context.draw_text(font, text, Vector(position.x, position.y), ALIGN_LEFT, layer, color);
#include <string>
#include <vector>
+#include <memory>
#include "video/color.hpp"
Font* font;
Color color;
std::string text;
- Surface* image;
+ std::auto_ptr<Surface> image;
private:
InfoBoxLine(const InfoBoxLine&);
{
reset();
- coin_surface.reset(new Surface("images/engine/hud/coins-0.png"));
+ coin_surface = Surface::create("images/engine/hud/coins-0.png");
sound_manager->preload("sounds/coin.wav");
sound_manager->preload("sounds/lifeup.wav");
}
lines = InfoBoxLine::split(text, SCREEN_WIDTH - 2*LEFT_BORDER);
// load background image
- background.reset(new Surface("images/background/" + background_file));
+ background = Surface::create("images/background/" + background_file);
scroll = 0;
fading = false;
#include "video/texture.hpp"
#include "video/video_systems.hpp"
+std::auto_ptr<Surface>
+Surface::create(const std::string& file)
+{
+ return std::auto_ptr<Surface>(new Surface(file));
+}
+
+std::auto_ptr<Surface>
+Surface::create(const std::string& file, int x, int y, int w, int h)
+{
+ return std::auto_ptr<Surface>(new Surface(file, x, y, w, h));
+}
+
+std::auto_ptr<Surface>
+Surface::create(const Surface& other)
+{
+ return std::auto_ptr<Surface>(new Surface(other));
+}
+
Surface::Surface(const std::string& file) :
texture(texture_manager->get(file)),
surface_data(),
#define HEADER_SUPERTUX_VIDEO_SURFACE_HPP
#include <string>
+#include <memory>
#include "math/vector.hpp"
*/
class Surface
{
+public:
+ static std::auto_ptr<Surface> create(const std::string& file);
+ static std::auto_ptr<Surface> create(const std::string& file, int x, int y, int w, int h);
+ static std::auto_ptr<Surface> create(const Surface& other);
+
private:
Texture* texture;
void *surface_data;