// ****************************************************************************
//
// Logic 23: Ferry boat
//
// ****************************************************************************

#include "defines.txt"

if (new_room) {
  load.pic(room_no);
  draw.pic(room_no);
  discard.pic(room_no);
  set.horizon(37);



// Check what room the player came from and position them on the
// screen accordingly here, e.g:
 if (prev_room_no == 22){
   position(ego,97,53);
   }

 if (prev_room_no==23 &&
     on_raft) {
     program.control();
     ego_dir=7;
     }

 if (prev_room_no == 24) {
   program.control();
   ego_dir=3;
   }

  if(!on_raft){
  animate.obj(o1);
  load.view(17);
  set.view(o1,17);
  set.loop(o1,2);
  universe=5;
  cycle.time(o1,universe);
  set.priority(o1,4);
  position(o1,14,110);
  draw(o1);
  }

  load.sound(9);
  sound(9, sound_flag);

  draw(ego);
  show.pic();
}



if (said("look")) {
  if (!on_raft) {
  print("This is the dock for the ferry.  The ferry boat is tied to the dock.");
  }
  else {
  print("Row! Row! Row your ferry...");
  }
}

if (said("look","boat")) {
   print("It's a nice, little raft with a spell cast on it to carry you safely  to the other side.");
   }

if (said("look","dock")) {
    print("It's a sturdy, union job.");
    }

if (said("look","path")) {
    print("From the dock, the path trails up to a fork in the road.");
    }

if (said("look","water")) {
    print("The river flows much more calmly here, making it suffice as the ferry crossing.");
    }

if (said("look","beach")) {
    print("These beaches are free of any ingredients you might need.");
    }

if ((said("use","raft") ||
     said("take","raft"))) {
          print("It is sufficient to just get on the raft.");
          }


if (new_ego_x<20 &&
    !on_raft) {
    program.control();
    erase(o1);
    reposition.to(ego,14,110);
    set.view(ego,17);
    ego_dir=7;
    set(on_raft);
    new.room(23);
    }

if (new_ego_x>15 &&
    on_raft) {
    load.view(0);
    set.view(ego,0);
    reset(on_raft);
    reposition.to(ego,22,96);
    new.room(23);
    }

if (ego_edge_code == horizon_edge) {  // ego touching horizon
  new.room(22);
}

if (ego_edge_code == left_edge) {     // ego touching left edge of screen
  new.room(24);
}

if (sound_flag) {
    sound(9,sound_flag);
    }

return();