// ****************************************************************************
//
// Logic 47: 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(2);
  load.view(1);

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

  if (bridge_switch) {
      animate.obj(o1);
      load.view(108);
      set.view(o1,108);
      position(o1,54,155);
      draw(o1);
      }

  animate.obj(o2); //vase
  load.view(112);
  set.view(o2,112);
  position(o2,16,97);
  draw(o2);

  animate.obj(o3); //deathbat
  load.view(130);
  set.view(o3,130);
  ignore.objs(o3);
  wander(o3);
  position(o3,71,21);
  draw(o3);

  load.sound(14);
  sound(14, 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("There are some creepy statues here, and as much as you'd like them out of the way, they are firmly cemented to the floor.");
          }

if ((said("look","bat") ||
     said("look","creature"))) {
          print("Yuk!  It's a Dream Bat!");
          }

if (said("look","bridge")) {
    if (bridge_switch) {
        print("The bridge looks sturdy enough to cross.");
        }
    else {
        print("There should probably be a bridge here...  Maybe they have something like Mama Hoodoo's Collapsible-Relapsible Bridge.");
        }
    }

if (said("look","hole")) {
    if (bridge_switch) {
        print("It is safe to cross the pit now.");
        }
    else {
        print("Not too close, girl!  You don't want to fall down there.");
        }
    }

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

if ((said("get","bat") ||
     said("get","creature"))) {
         print("No, he might have cooties or something.");
         }



if (ego_touching_signal_line && !bridge_switch ) {  // ego touching signal line
    ego_dir=5;
    if (is_zombie) {
        set.view(ego, 129);
        }
    else {
        set.view(ego,1);
        }
    universe=2;
    step.size(ego,universe);
    get.posn(ego,temp_x,temp_y);
    if (temp_y>166) {
        new.room(204);
        }
}

if (ego_on_water) {
    if (is_zombie) {
        set.view(ego, 129);
        }
    else {
       set.view(ego, 2);
       }
    }
else {
   if (is_zombie) {
       set.view(ego, 103);
       }
   else {
       set.view(ego,0);
       }
   }

//Deathbat collision detection
temp_x=new_ego_x;
temp_x+=12;
temp_y=new_ego_y;
temp_y-=44;
get.posn(o3,temp_x2,temp_y2);
temp_x2+=9;
if (temp_x2>new_ego_x &&
    temp_x2<temp_x &&
    temp_y2>temp_y &&
    temp_y2<new_ego_y) {
    print("Bat: \"Squeak!  Squeak!\"");
    }


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

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

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

return();