// ****************************************************************************
//
// Logic 48: Inside the Gates to the Castle
//
// ****************************************************************************

#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 == 44) {
     position(ego,44,72);
     ego_dir = 5;
 }*/

  load.view(1);
  load.view(2);
  if (is_zombie) {
      load.view(103);
      load.view(129);
      }

  animate.obj(o1); //guard
  load.view(107);
  set.view(o1,107);
  position(o1,121,152);
  ignore.objs(o1);
  draw(o1);

  block_xr = 126; //right side of urn

  animate.obj(o2); //broken urn
  load.view(113);
  set.view(o2, 113);
  position(o2, 119,97);
  step.size(o2, universe);
  if (is_zombie) {
     ignore.objs(o2);
     }
  draw(o2);

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

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

if (said("look")) {
  print("You are inside the gate to the castle.");
}

if ((said("look","ladder") ||
     said("climb","ladder"))) {
          print("It looks sturdy enough.  Just push up or down when you're centered on the ladder to climb.");
          }

if ((said("look","statue") ||
     said("push","statue") ||
     said("get","statue"))) {
          print("The base of this statue is loose, but you'd need zombie-like strenght to actually move it.");
          }

if (said("look","guard")) {
    print("He may seem puny, but he's a trained fighter.");
    }

if (said("jump")) {
    print("This is a non-jumping game.");
    }

if (said("attack","guard")) {
    print("You're no fighter!");
    }

get.posn(o1, temp_x, temp_y);

distance(o1, ego, temp_x2);

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

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

if (temp_x2<=10) {

     print("You've been captured by the Dream King's guards and sent outside.");
     new.room(44);
     }

if(is_zombie) {
  get.posn(ego,temp_x,temp_y);
  get.posn(o2,temp_x2,temp_y2);

  if (temp_x<block_xr &&
      temp_x>40 &&
      temp_y==97 &&
      temp_y2==97) {
      move.obj(o2,109,97,2,done_flag);


      }
    else {
    stop.motion(o2);
    }
}

if (done_flag) {
    move.obj(o2,109,156,2,more_done_flag);
    }

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

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

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

call(100);

return();