// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
+#include <algorithm>
#include "ghosttree.hpp"
#include "treewillowisp.hpp"
{
glow_sprite.reset(sprite_manager->create("images/creatures/ghosttree/ghosttree-glow.sprite"));
set_colgroup_active(COLGROUP_TOUCHABLE);
+ sound_manager->preload("sounds/tree_howling.ogg");
+ sound_manager->preload("sounds/tree_suck.ogg");
}
GhostTree::~GhostTree()
Color col;
switch(treecolor) {
- case 0: col = Color(1, 0, 0); break;
- case 1: col = Color(0, 1, 0); break;
- case 2: col = Color(0, 0, 1); break;
- case 3: col = Color(1, 1, 0); break;
- case 4: col = Color(1, 0, 1); break;
- case 5: col = Color(0, 1, 1); break;
- default: assert(false);
+ case 0: col = Color(1, 0, 0); break;
+ case 1: col = Color(0, 1, 0); break;
+ case 2: col = Color(0, 0, 1); break;
+ case 3: col = Color(1, 1, 0); break;
+ case 4: col = Color(1, 0, 1); break;
+ case 5: col = Color(0, 1, 1); break;
+ default: assert(false);
}
glow_sprite->set_color(col);
}
sound_manager->play("sounds/tree_suck.ogg", get_pos());
std::vector<TreeWillOWisp*>::iterator iter;
for(iter = willowisps.begin(); iter != willowisps.end(); ++iter) {
- TreeWillOWisp *willo = *iter;
- if(willo->get_color() == col) {
- willo->start_sucking(get_bbox().get_middle() + SUCK_TARGET_OFFSET + Vector(systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD), systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD)));
- }
+ TreeWillOWisp *willo = *iter;
+ if(willo->get_color() == col) {
+ willo->start_sucking(get_bbox().get_middle() + SUCK_TARGET_OFFSET + Vector(systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD), systemRandom.randf(-SUCK_TARGET_SPREAD, SUCK_TARGET_SPREAD)));
+ }
}
mystate = STATE_SUCKING;
}
if(willowisp_timer.check()) {
if(willowisps.size() < WILLOWISP_COUNT) {
- Vector pos = Vector(bbox.get_width() / 2, bbox.get_height() / 2 + willo_spawn_y + WILLOWISP_TOP_OFFSET);
- TreeWillOWisp *willowisp
- = new TreeWillOWisp(this, pos, 200 + willo_radius, willo_speed);
-
- Sector::current()->add_object(willowisp);
- willowisps.push_back(willowisp);
-
- willo_spawn_y -= 40;
- if(willo_spawn_y < -160)
- willo_spawn_y = 0;
-
- willo_radius += 20;
- if(willo_radius > 120)
- willo_radius = 0;
-
- if(willo_speed == 1.8f) {
- willo_speed = 1.5f;
- } else {
- willo_speed = 1.8f;
- }
-
- do {
- willo_color = (willo_color + 1) % 3;
- } while(willo_color == treecolor);
-
- switch(willo_color) {
- case 0: willowisp->set_color(Color(1, 0, 0)); break;
- case 1: willowisp->set_color(Color(0, 1, 0)); break;
- case 2: willowisp->set_color(Color(0, 0, 1)); break;
- case 3: willowisp->set_color(Color(1, 1, 0)); break;
- case 4: willowisp->set_color(Color(1, 0, 1)); break;
- case 5: willowisp->set_color(Color(0, 1, 1)); break;
- default: assert(false);
- }
+ Vector pos = Vector(bbox.get_width() / 2, bbox.get_height() / 2 + willo_spawn_y + WILLOWISP_TOP_OFFSET);
+ TreeWillOWisp *willowisp
+ = new TreeWillOWisp(this, pos, 200 + willo_radius, willo_speed);
+
+ Sector::current()->add_object(willowisp);
+ willowisps.push_back(willowisp);
+
+ willo_spawn_y -= 40;
+ if(willo_spawn_y < -160)
+ willo_spawn_y = 0;
+
+ willo_radius += 20;
+ if(willo_radius > 120)
+ willo_radius = 0;
+
+ if(willo_speed == 1.8f) {
+ willo_speed = 1.5f;
+ } else {
+ willo_speed = 1.8f;
+ }
+
+ do {
+ willo_color = (willo_color + 1) % 3;
+ } while(willo_color == treecolor);
+
+ switch(willo_color) {
+ case 0: willowisp->set_color(Color(1, 0, 0)); break;
+ case 1: willowisp->set_color(Color(0, 1, 0)); break;
+ case 2: willowisp->set_color(Color(0, 0, 1)); break;
+ case 3: willowisp->set_color(Color(1, 1, 0)); break;
+ case 4: willowisp->set_color(Color(1, 0, 1)); break;
+ case 5: willowisp->set_color(Color(0, 1, 1)); break;
+ default: assert(false);
+ }
}
}