const float RIGHT_JUMP_X = RIGHT_STAND_X-448; /**< 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 */
const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */
-const int INITIAL_HITPOINTS = 9; /**< number of hits we can take */
+const int INITIAL_HITPOINTS = 5; /**< number of hits we can take */
const float YETI_SQUISH_TIME = 5;
}
{
hit_points = INITIAL_HITPOINTS;
countMe = false;
- sound_manager->preload("sounds/yeti_gna.wav");
- sound_manager->preload("sounds/yeti_roar.wav");
+ SoundManager::current()->preload("sounds/yeti_gna.wav");
+ SoundManager::current()->preload("sounds/yeti_roar.wav");
hud_head = Surface::create("images/creatures/yeti/hudlife.png");
}
void
Yeti::draw_hit_points(DrawingContext& context)
{
- int i;
-
if (hud_head)
{
context.push_transform();
context.set_translation(Vector(0, 0));
- for (i = 0; i < hit_points; ++i)
+ for (int i = 0; i < hit_points; ++i)
{
context.draw_surface(hud_head, Vector(BORDER_X + (i * hud_head->get_width()), BORDER_Y + 1), LAYER_FOREGROUND1);
}
break;
case BE_ANGRY:
if(state_timer.check()) {
- sound_manager->play("sounds/yeti_gna.wav");
+ SoundManager::current()->play("sounds/yeti_gna.wav");
physic.set_velocity_y(STOMP_VY);
sprite->set_action((dir==RIGHT)?"stomp-right":"stomp-left");
}
if(safe_timer.started())
return;
- sound_manager->play("sounds/yeti_roar.wav");
+ SoundManager::current()->play("sounds/yeti_roar.wav");
hit_points--;
if(hit_points <= 0) {
physic.set_velocity_x(0);
physic.set_velocity_y(0);
+ // Set the badguy layer to be above the foremost, so that
+ // this does not reveal secret tilemaps:
+ layer = Sector::current()->get_foremost_layer() + 1;
state = SQUISHED;
state_timer.start(YETI_SQUISH_TIME);
set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC);
Sector* sector = Sector::current();
for(Sector::GameObjects::iterator i = sector->gameobjects.begin();
i != sector->gameobjects.end(); ++i) {
- YetiStalactite* stalactite = dynamic_cast<YetiStalactite*> (*i);
+ YetiStalactite* stalactite = dynamic_cast<YetiStalactite*>(i->get());
if(stalactite && stalactite->is_hanging()) {
- float distancex;
- switch (hit_points) {
- case 9:
- case 8:
- case 7:
- case 6:
- // drop stalactites within 3 of player, going out with each jump
- distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
- if(distancex < stomp_count*32) {
- stalactite->start_shaking();
- }
- break;
- case 5:
- case 4:
- case 3:
- case 2:
- case 1:
- // drop every 3rd stalactite
- if(((((int)stalactite->get_pos().x + 16) / 32) % 3) == (stomp_count % 3)) {
- stalactite->start_shaking();
- }
- break;
+ if (hit_points >= 3) {
+ // drop stalactites within 3 of player, going out with each jump
+ float distancex = fabsf(stalactite->get_bbox().get_middle().x - player->get_bbox().get_middle().x);
+ if(distancex < stomp_count*32) {
+ stalactite->start_shaking();
+ }
}
- }
+ else { /* if (hitpoints < 3) */
+ // drop every 3rd pair of stalactites
+ if(((((int)stalactite->get_pos().x + 16) / 64) % 3) == (stomp_count % 3)) {
+ stalactite->start_shaking();
+ }
+ }
+ } /* if(stalactite && stalactite->is_hanging()) */
}
}