void BadGuy::collision_solid(const CollisionHit& hit) { m_physic.set_velocity_x(0); m_physic.set_velocity_y(0); update_on_ground_flag(hit); }
void MrIceBlock::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if(hit.top || hit.bottom) { // floor or roof physic.set_velocity_y(0); } // hit left or right switch(ice_state) { case ICESTATE_NORMAL: WalkingBadguy::collision_solid(hit); break; case ICESTATE_KICKED: { if((hit.right && dir == RIGHT) || (hit.left && dir == LEFT)) { dir = (dir == LEFT) ? RIGHT : LEFT; SoundManager::current()->play("sounds/iceblock_bump.wav", get_pos()); physic.set_velocity_x(-physic.get_velocity_x()*.975); } this->set_action(dir == LEFT ? "flat-left" : "flat-right", /* loops = */ -1); if(fabsf(physic.get_velocity_x()) < walk_speed*1.5) set_state(ICESTATE_NORMAL); break; } case ICESTATE_FLAT: physic.set_velocity_x(0); break; case ICESTATE_GRABBED: break; } }
void Totem::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); // if we are being carried around, pass event to bottom of stack and ignore it if (carried_by) { carried_by->collision_solid(hit); return; } // If we hit something from above or below: stop moving in this direction if (hit.top || hit.bottom) { physic.set_velocity_y(0); } // If we are hit from the direction we are facing: turn around if (hit.left && (dir == LEFT)) { dir = RIGHT; initialize(); } if (hit.right && (dir == RIGHT)) { dir = LEFT; initialize(); } }
void Bomb::collision_solid(const CollisionHit& hit) { if(hit.bottom) physic.set_velocity_y(0); update_on_ground_flag(hit); }
void Bomb::collision_solid(const CollisionHit& hit) { if(grabbed) { return; } if(hit.top || hit.bottom) physic.set_velocity_y(0); if(hit.left || hit.right) physic.set_velocity_x(-physic.get_velocity_x()); if(hit.crush) physic.set_velocity(0, 0); update_on_ground_flag(hit); }
void GoldBomb::collision_solid(const CollisionHit& hit) { if(tstate == STATE_TICKING) { if(hit.bottom) { physic.set_velocity_y(0); physic.set_velocity_x(0); }else if (hit.left || hit.right) physic.set_velocity_x(-physic.get_velocity_x()); else if (hit.top) physic.set_velocity_y(0); update_on_ground_flag(hit); return; } WalkingBadguy::collision_solid(hit); }
void WalkingBadguy::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if (hit.top) { if (physic.get_velocity_y() < 0) physic.set_velocity_y(0); } if (hit.bottom) { if (physic.get_velocity_y() > 0) physic.set_velocity_y(0); } if ((hit.left && (hit.slope_normal.y == 0) && (dir == LEFT)) || (hit.right && (hit.slope_normal.y == 0) && (dir == RIGHT))) { turn_around(); } }
void WalkingBadguy::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if (hit.top) { if (m_physic.get_velocity_y() < 0) m_physic.set_velocity_y(0); } if (hit.bottom) { if (m_physic.get_velocity_y() > 0) m_physic.set_velocity_y(0); } if ((hit.left && (m_dir == Direction::LEFT)) || (hit.right && (m_dir == Direction::RIGHT))) { turn_around(); } }
void Stumpy::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); switch (mystate) { case STATE_INVINCIBLE: if(hit.top || hit.bottom) { physic.set_velocity_y(0); } if(hit.left || hit.right) { physic.set_velocity_x(0); } break; case STATE_NORMAL: WalkingBadguy::collision_solid(hit); break; } }
HitResponse Jumpy::hit(const CollisionHit& chit) { if (chit.bottom) { if (!groundhit_pos_set) { pos_groundhit = get_pos(); groundhit_pos_set = true; } m_physic.set_velocity_y((m_frozen || get_state() != STATE_ACTIVE) ? 0 : JUMPYSPEED); // TODO create a nice sound for this... //SoundManager::current()->play("sounds/skid.wav"); update_on_ground_flag(chit); } else if (chit.top) { m_physic.set_velocity_y(0); } return CONTINUE; }
void Yeti::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if(hit.top || hit.bottom) { // hit floor or roof physic.set_velocity_y(0); switch (state) { case JUMP_DOWN: run(); break; case RUN: break; case JUMP_UP: break; case BE_ANGRY: // we just landed if(!state_timer.started()) { sprite->set_action((dir==RIGHT)?"stand-right":"stand-left"); stomp_count++; drop_stalactite(); // go to other side after 3 jumps if(stomp_count == 3) { jump_down(); } else { // jump again state_timer.start(STOMP_WAIT); } } break; case SQUISHED: break; case FALLING: break; } } else if(hit.left || hit.right) { // hit wall jump_up(); } }
void Snail::collision_solid(const CollisionHit& hit) { if (m_frozen) { WalkingBadguy::collision_solid(hit); return; } switch (state) { case STATE_NORMAL: WalkingBadguy::collision_solid(hit); return; case STATE_KICKED: if (hit.left || hit.right) { SoundManager::current()->play("sounds/iceblock_bump.wav", get_pos()); if ( ( m_dir == Direction::LEFT && hit.left ) || ( m_dir == Direction::RIGHT && hit.right) ){ m_dir = (m_dir == Direction::LEFT) ? Direction::RIGHT : Direction::LEFT; m_sprite->set_action(m_dir == Direction::LEFT ? "flat-left" : "flat-right"); m_physic.set_velocity_x(-m_physic.get_velocity_x()); } } BOOST_FALLTHROUGH; case STATE_FLAT: case STATE_KICKED_DELAY: if (hit.top || hit.bottom) { m_physic.set_velocity_y(0); } break; case STATE_GRABBED: break; } update_on_ground_flag(hit); }
void MrIceBlock::collision_solid(const CollisionHit& hit) { update_on_ground_flag(hit); if(hit.top || hit.bottom) { // floor or roof physic.set_velocity_y(0); return; } // hit left or right switch(ice_state) { case ICESTATE_NORMAL: WalkingBadguy::collision_solid(hit); break; case ICESTATE_KICKED: { if(hit.right && dir == RIGHT) { dir = LEFT; sound_manager->play("sounds/iceblock_bump.wav", get_pos()); if(++squishcount >= MAXSQUISHES) { kill_fall(); break; } physic.set_velocity_x(-KICKSPEED); } else if(hit.left && dir == LEFT) { dir = RIGHT; sound_manager->play("sounds/iceblock_bump.wav", get_pos()); if(++squishcount >= MAXSQUISHES) { kill_fall(); break; } physic.set_velocity_x(KICKSPEED); } sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); break; } case ICESTATE_FLAT: physic.set_velocity_x(0); break; case ICESTATE_GRABBED: break; } }