1
// $Id: WeatherObj.cc,v 1.9 2001/08/12 18:36:41 grumbel Exp $
3
// Pingus - A free Lemmings clone
4
// Copyright (C) 2000 Ingo Ruhnke <grumbel@gmx.de>
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "../XMLhelper.hh"
21
#include "../PingusResource.hh"
22
#include "EditorView.hh"
23
#include "WeatherObj.hh"
25
WeatherObj::WeatherObj(const WeatherData& data)
26
: SpriteEditorObj (pos)
29
pos = CL_Vector(0,0,200);
34
sprite = Sprite("editor/weather_rain", "core");
36
else if (type == "snow")
38
sprite = Sprite("editor/weather_snow", "core");
42
std::cout << "WeatherObj: Unknown weather type: " << type << std::endl;
43
sprite = Sprite("editor/weather_rain", "core");
47
WeatherObj::~WeatherObj()
52
WeatherObj::draw (boost::dummy_ptr<EditorView> view)
54
std::cout << "Dragging: " << dragging << std::endl;
58
for (int x = 0; x < 320; x += sprite.get_width () + 4)
60
view->draw_fillrect (x, 0,
61
x + sprite.get_width (), sprite.get_height (),
62
1.0f, 1.0f, 1.0f, 0.5f);
66
CL_Vector tmp_pos (pos);
67
pos.x = int((pos.x + sprite.get_width ()/2)
68
/sprite.get_width ()) * sprite.get_width ();
69
pos.y = int((pos.y - sprite.get_height ()/2)
70
/sprite.get_height ()) * sprite.get_height ();
71
SpriteEditorObj::draw (view);
76
WeatherObj::write_xml(std::ofstream* xml)
78
(*xml) << " <weather>\n"
79
<< " <type>" << type << "</type>\n";
80
XMLhelper::write_position_xml(xml, pos);
81
(*xml) << " </weather>\n"
85
boost::shared_ptr<EditorObj>
86
WeatherObj::duplicate()
88
return boost::shared_ptr<EditorObj>(new WeatherObj(*this));
101
pos.x = int((pos.x + sprite.get_width ()/2)
102
/sprite.get_width ()) * sprite.get_width ();
103
pos.y = int((pos.y - sprite.get_height ()/2)
104
/sprite.get_height ()) * sprite.get_height ();