// ****************************************************************************
//
// Logic 4: Ego Mouse Control Test Room
//
// ****************************************************************************

#include "defines.txt"

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

  show.pic();

  animate.obj(o2);
  load.view(3);
  set.view(o2,3);
}

if(mouse_button == mb_left) {
  // If the user clicks on the help icon
  if(mouse_y > 7 && mouse_y < 20 && mouse_x < 12) {
     print("Welcome to the AGI Mouse Target Practice Demo.\nLeft click anywhere on the screen to shoot your AGI Mouse gun!");
  } else {
    // If the user clicks on the exit icon
    if(mouse_y > 7 && mouse_y < 20 && mouse_x > 148) {
       new.room(2);
    } else {
      // If the user clicks any other area, draw a bullet hole
      if(mouse_y > 30 && mouse_y < 176 && mouse_x > 2 && mouse_x < 158) {
        mouse_x -= 4;
        if(!isset(f250)) {
          position.v(o2,mouse_x,mouse_y);
          end.of.loop(o2,f255);
        } else {
          set.cel(o2,2);
        }
        draw(o2);
      }
    }
  } 
}

if(isset(f255)) {
  stop.update(o2);
  set.cel(o2,0);
  reset(f255);
}

return();
