// ****************************************************************************
//
// Logic 77: Underwater
//
// ****************************************************************************

#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 == 5) {
//   position(ego,12,140);
// }
  animate.obj(o1); //shark
  load.view(119);
  set.view(o1,119);
  position(o1,65,71);
  ignore.objs(o1);
  draw(o1);

    if (golden_caul == 6) {
      animate.obj(o2);        //golden cauldron shard
      load.view(132);
      set.view(o2,132);
      position(o2,15,143);
      ignore.objs(o2);
      draw(o2);
      }

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


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

get.posn(o1,temp_x, temp_y);
distance(o1,ego,range);

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

if ((said("look","fragment") ||
     said("look","shard"))) {
         if (golden_caul == 6) {
             print("You see a glittering golden shard.");
             }
         else {
             if (has("golden shard")) {
                 show.obj(gold_shard);
                 }
             else {
                 print("Nothing to see here.");
                 }
          }
     }

if ((said("take","fragment") ||
     said("take","shard"))) {
   if (golden_caul == 6) {
     distance(o2, ego, universe);
     if ( universe <= 10) {
       print("You found another fragment of the cauldron.");
       erase(o2);
       score++;
       golden_caul++;
        }
      else {
        print("So close...  but not close enough!");
        }
       }
   else {
      print("No cheating, kid.");
      }
   }

if (temp_x>=101) {
    universe=7;
    set.dir(o1,universe);
    }

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

if (range<=5) {
    print("Gak!  You've been eaten!");
    new.room(204);
    }
if (ego_edge_code == horizon_edge) {  // ego touching horizon
  new.room(73);
}

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

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

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

call (201);

return();