void Monster::move(Map *map) { set_ay(get_attribute("weight")); switch(m_action) { case Still: break; case Move: Body::move(map); if (get_fall()) { set_action(Fall); } break; case Fall: Body::move(map); if (!get_fall()) { m_hit_ground = true; set_vx(0); set_action(Still); } break; case Jump: Body::move(map); if (get_fall()) { set_action(Still); } break; case Hit: if (m_hit == HitPerish) { set_vx(0); if (m_perish_timer.expired(get_attribute("perish_time"))) { m_hit = HitPerished; } } else if (m_hit_timer.expired(get_attribute("hit_time"))) { m_hit_timer.reset(); set_vx(0); set_lock_direction(false); m_hit = HitNone; set_action(Still); } Body::move(map); break; default: break; } }
void Material::move(Map *map) { if (!m_ref_done) { int dx; if (m_from_chest) { dx = get_attribute("chest_speed"); } else { dx = get_attribute("move_speed"); } if (get_reference() == Right) { set_speed(dx, -get_attribute("rise_speed")); } else { set_speed(-dx, -get_attribute("rise_speed")); } set_accelration(0, get_attribute("weight")); m_ref_done = true; } Body::move(map); if (get_moving()) { animate_move(); } else { m_frame = get_attribute("move_still"); } if (get_fall()) { m_reachable = true; } }
void Monster::move(Map *map) { switch(m_action) { case Still: set_vx(0); break; case Move: Body::move(map); if (get_fall()) { set_action(Fall); } break; case Fall: Body::move(map); if (!get_fall()) { m_hit_ground = true; set_vx(0); set_action(Still); } break; case Jump: Body::move(map); if (get_fall()) { set_action(Fall); } break; case Hit: case HitPerish: process_hit(); Body::move(map); break; default: break; } }
void Player::player_move(Map *map) { Actor::move(map); check_water(map); int input = get_input(); const Tmx::Tileset *tileset = map->get_tileset(0); const Tmx::PropertySet prop = tileset->GetProperties(); // Check if on catapult int catid = prop.GetNumericProperty("catapult"); if (catid && check_below(map, 1, catid, catid) == 0) { if (input & PRESS_RIGHT) { set_vx(get_attribute("move_speed")); } else if (input & PRESS_LEFT) { set_vx(-get_attribute("move_speed")); } set_jump(map, true); } switch(m_action) { case Still: set_vx(0); case Move: // Check for crouch or move if (input & PRESS_DOWN) { set_action(Crouch); } else if (input & PRESS_RIGHT) { animate_move(); set_action(Move); set_vx(get_attribute("move_speed")); } else if (input & PRESS_LEFT) { animate_move(); set_action(Move); set_vx(-get_attribute("move_speed")); } else { set_action(Still); } // Check for jump if (input & PRESS_JUMP) { if (m_jump_ready && m_hit_ground) { if (input & PRESS_RIGHT) { set_vx(get_attribute("move_speed")); } else if (input & PRESS_LEFT) { set_vx(-get_attribute("move_speed")); } set_jump(map, false); } m_jump_ready = false; } else { // Restore jump lock m_jump_ready = true; } Body::move(map); if (get_fall()) { set_action(Fall); } break; case Fall: // Check for change of direction during fall if (input & PRESS_RIGHT) { set_vx(get_attribute("move_speed")); } else if (input & PRESS_LEFT) { set_vx(-get_attribute("move_speed")); } Body::move(map); if (!get_fall()) { m_hit_ground = true; set_action(Still); } break; case Jump: case Catapult: Body::move(map); if (get_fall()) { set_action(Fall); } break; case Crouch: set_vx(0); Body::move(map); if (!get_fall()) { m_hit_ground = true; } if (!(input & PRESS_DOWN)) { set_action(Still); } break; case Hit: if (m_hit_timer.expired(get_attribute("hit_time"))) { set_vx(0); set_lock_direction(false); reset_hit(); } Body::move(map); break; case HitPerish: animate_perish(); set_speed(0, -get_attribute("move_speed")); Body::move(map); if (m_y < -get_image_height()) { set_solid(true); set_invisible(false); set_action(HitPerished); } break; case Attack: case AttackLow: if (animate_attack()) { reset_attack(); } Body::move(map); if (!get_fall()) { m_hit_ground = true; } break; default: Body::move(map); break; } }
void Player::player_move(Map *map) { const Tmx::Tileset *tileset = map->get_tileset(0); const Tmx::PropertySet prop = tileset->GetProperties(); // Check if under water int start = prop.GetNumericProperty("water_start"); int end = prop.GetNumericProperty("water_end"); if (start && check_ahead(map, 1, start, end) == 0) { if (!m_water_timer.expired(get_attribute("water_treshold"))) { return; } m_water_timer.reset(); } // Check if on catapult int catid = prop.GetNumericProperty("catapult"); if (catid && check_below(map, 1, catid, catid) == 0) { set_vy(int(-get_attribute("catapult_speed"))); set_action(Jump); } Actor::move(map); set_ay(get_attribute("weight")); int input = get_input(); switch(m_action) { case Still: set_vx(0); case Move: // Check for jump if (input & PRESS_JUMP) { if (m_jump_ready) { m_jump_ready = false; set_action(Jump); if (input & PRESS_RIGHT) { set_speed(get_attribute("jump_forward"), -get_attribute("jump_speed")); } else if (input & PRESS_LEFT) { set_speed(-get_attribute("jump_forward"), -get_attribute("jump_speed")); } else { set_vy(-get_attribute("jump_speed")); } } } else { // Restore jump lock m_jump_ready = true; // Check for crouch or move if (input & PRESS_DOWN) { set_action(Crouch); } else if (input & PRESS_RIGHT) { animate_move(); set_action(Move); set_vx(get_attribute("move_speed")); } else if (input & PRESS_LEFT) { animate_move(); set_action(Move); set_vx(-get_attribute("move_speed")); } else { set_action(Still); set_vx(0); } } Body::move(map); if (get_fall()) { set_action(Fall); } break; case Fall: // Check for change of direction during fall if (input & PRESS_RIGHT) { set_vx(get_attribute("jump_forward")); } else if (input & PRESS_LEFT) { set_vx(-get_attribute("jump_forward")); } Body::move(map); if (!get_fall()) { set_action(Still); } break; case Jump: Body::move(map); if (get_fall()) { set_action(Fall); } break; case Crouch: set_vx(0); Body::move(map); if (!(input & PRESS_DOWN)) { set_action(Still); } break; case Hit: if (m_hit_timer.expired(get_attribute("hit_time"))) { m_hit_timer.reset(); set_vx(0); set_lock_direction(false); m_hit = HitNone; set_action(Still); } Body::move(map); break; default: Body::move(map); break; } }