// $Id$
-//
+//
// SuperTux - Boss "Yeti"
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
// 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
namespace {
const float JUMP_DOWN_VX = 250; /**< horizontal speed while jumping off the dais */
- const float JUMP_DOWN_VY = 250; /**< vertical speed while jumping off the dais */
+ const float JUMP_DOWN_VY = -250; /**< vertical speed while jumping off the dais */
const float RUN_VX = 350; /**< horizontal speed while running */
const float JUMP_UP_VX = 350; /**< horizontal speed while jumping on the dais */
- const float JUMP_UP_VY = 800; /**< vertical speed while jumping on the dais */
+ const float JUMP_UP_VY = -800; /**< vertical speed while jumping on the dais */
- const float STOMP_VY = 250; /** vertical speed while stomping on the dais */
+ const float STOMP_VY = -250; /** vertical speed while stomping on the dais */
const float LEFT_STAND_X = 16; /**< x-coordinate of left dais' end position */
- const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */
+ const float RIGHT_STAND_X = 800-60-16; /**< x-coordinate of right dais' end position */
const float LEFT_JUMP_X = LEFT_STAND_X+224; /**< x-coordinate of from where to jump on the left dais */
const float RIGHT_JUMP_X = RIGHT_STAND_X-224; /**< x-coordinate of from where to jump on the right dais */
const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again */
}
Yeti::Yeti(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/yeti/yeti.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- bbox.set_size(60, 90);
- sprite = sprite_manager->create("images/creatures/yeti/yeti.sprite");
hit_points = INITIAL_HITPOINTS;
reader.get("dead-script", dead_script);
countMe = false;
+ sound_manager->preload("sounds/yeti_gna.wav");
+ sound_manager->preload("sounds/yeti_roar.wav");
}
Yeti::~Yeti()
void
Yeti::summon_snowball()
{
- Sector::current()->add_object(new BouncingSnowball(get_pos().x+(dir == RIGHT ? 64 : -64), get_pos().y, dir));
+ Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x+(dir == RIGHT ? 64 : -64), get_pos().y), dir));
}
bool
physic.enable_gravity(true);
physic.set_velocity_x(0);
physic.set_velocity_y(0);
-
+
state = SQUISHED;
state_timer.start(SQUISH_TIME);
set_group(COLGROUP_MOVING_ONLY_STATIC);
i != sector->gameobjects.end(); ++i) {
YetiStalactite* stalactite = dynamic_cast<YetiStalactite*> (*i);
if(stalactite && stalactite->is_hanging()) {
- float sdist
+ float sdist
= fabsf(stalactite->get_pos().x - player->get_pos().x);
if(sdist < dist) {
nearest = stalactite;
nearest->start_shaking();
}
-HitResponse
-Yeti::collision_solid(GameObject& , const CollisionHit& hit)
+void
+Yeti::collision_solid(const CollisionHit& hit)
{
- if(fabsf(hit.normal.y) > .5) {
+ if(hit.top || hit.bottom) {
// hit floor or roof
physic.set_velocity_y(0);
switch (state) {
case SQUISHED:
break;
}
- } else
- if(fabsf(hit.normal.x) > .5) {
+ } else if(hit.left || hit.right) {
// hit wall
jump_up();
}
-
- return CONTINUE;
}
IMPLEMENT_FACTORY(Yeti, "yeti")