diff options
author | Stijn Buys <ingar@osirion.org> | 2008-09-28 21:34:53 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-09-28 21:34:53 +0000 |
commit | 9252bfb61fabea1f45afacb19d805eb5fdd01599 (patch) | |
tree | 13fdfb005ab0b690766d35572f0eeecca28f6009 /src/game/intro/convoy.cc | |
parent | 6774f2b5d14c1957d163ef4b7914c2660b59fdfd (diff) |
intro module
Diffstat (limited to 'src/game/intro/convoy.cc')
-rw-r--r-- | src/game/intro/convoy.cc | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/game/intro/convoy.cc b/src/game/intro/convoy.cc new file mode 100644 index 0000000..ea71a27 --- /dev/null +++ b/src/game/intro/convoy.cc @@ -0,0 +1,85 @@ +/* + intro/convoy.h + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include "intro/convoy.h" + +namespace intro { + +Member::Member(std::string const &model) : core::EntityControlable(0, 1) +{ + set_name("Convoy member"); + set_label(model); + + entity_modelname = "ships/" + model; + + entity_thrust = 1.0f; + entity_speed = 1.0f; + + entity_location.x = -16.0f; + entity_location.y = -math::randomf(8.0f); + entity_location.z = math::randomf(8.0f) - 6.0f; + + entity_axis.change_direction(15.0f); +} + +Member::~Member() +{ +} + +void Member::frame(float seconds) +{ + entity_location += entity_axis.forward() * speed() * thrust() * seconds; +} + +Convoy::Convoy(core::Zone *zone) +{ + convoy_zone = zone; +} + +Convoy::~Convoy() +{ + convoy_members.clear(); +} + +void Convoy::set_color(math::Color const &color) +{ + convoy_color.assign(color); +} +void Convoy::set_color_second(math::Color const &color) +{ + convoy_color_second.assign(color); +} + +void Convoy::add(const char *model) +{ + add(std::string(model)); +} + +void Convoy::add(std::string const &model) +{ + Member *member = new Member(model); + convoy_members.push_back(member); + member->set_zone(convoy_zone); + member->entity_color.assign(convoy_color); + member->entity_color_second.assign(convoy_color_second); +} + +void Convoy::frame(float seconds) +{ + for (Members::iterator it = convoy_members.begin(); it != convoy_members.end(); ) { + Member *member = (*it); + if (member->location().length() > 64.0f) { + std::string model(member->label()); + member->die(); + convoy_members.erase(it++); + add(model); + } else { + ++it; + } + } +} + +}
\ No newline at end of file |