// ****************************************************************************
//
// Logic 69: Underwater Entrance to hidden chamber of treasure
//
// ****************************************************************************

#include "defines.txt"

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


// Check what room the player came from and position them on the
// screen accordingly here, e.g:
 if (prev_room_no == 83) {
   position(ego,31,18);
 }
  animate.obj(o1); //sharks
  animate.obj(o2);
  animate.obj(o3);
  load.view(119);
  set.view(o1,119);
  set.view(o2,119);
  set.view(o3,119);
  position(o1,17,154);
  position(o2,29,112);
  position(o3,80,58);
  ignore.objs(o1);
  ignore.objs(o2);
  ignore.objs(o3);
  draw(o1);
  draw(o2);
  draw(o3);

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


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

get.posn(o1,temp_x,temp_y); //where the sharks at/
get.posn(o2,temp_x2,temp_y);
get.posn(o3,temp_x3,temp_y);

distance(o1, ego, range); //how close is ego to shark
distance(o2, ego, temp_y2);
distance(o3, ego, temp_y3);

if (said("look")) {
  print("You are deep in the artificial night of these Stygian waters.");
}

if (temp_x>=48) {  //move the sharks back and forth
    universe=7;
    set.dir(o1,universe);
    }

if (temp_x<=17) {
    universe=3;
    set.dir(o1, universe);
    }

if (temp_x2>=64) {
    universe=7;
    set.dir(o2, universe);
    }

if (temp_x2<=29) {
    universe=3;
    set.dir(o2, universe);
    }

if (temp_x3>=114) {
    universe=7;
    set.dir(o3,universe);
    }

if (temp_x3<=80) {
    universe=3;
    set.dir(o3,universe);
    }

if ((range<=5 ||     //Eaten by sharks?
     temp_y2<=5 ||
     temp_y3<=5)) {
    print("You have been torn to pieces by sharks.");
    new.room(204);
    }

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

if (ego_edge_code == right_edge) {    // ego touching right edge of screen
  new.room(70);
}

if (ego_edge_code == bottom_edge) {   // ego touching bottom edge of screen
  new.room(73);
}

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

call (201);

return();