// ****************************************************************************
//
// Logic 5: AGI Mouse Drawing App
//
// ****************************************************************************

#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(o1);
  load.view(5);
  set.view(o1,5);
  set.cel(o1,0);
  stop.cycling(o1);
}

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 AGI Mouse Paint.\nClick on the palette on the bottom of the screen, then drag the mouse on the drawing canvas to draw in that colour!");
  } 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 < 160 && mouse_x > 2 && mouse_x < 158) {
        mouse_y -= 8;

        position.v(o1,mouse_x,mouse_y);
        draw(o1);
      } else {
        if(mouse_y > 160 && mouse_y < 176 && mouse_x > 2 && mouse_x < 151) {
          mouse_x -= 7;
          mouse_x /= 9;
          set.cel.v(o1,mouse_x);
        }
      }
    }
  } 
}

return();