import javax.swing.JPanel;
import java.awt.event.*;
import java.awt.event.MouseAdapter;
import java.awt.*;
import java.awt.Point;
import java.awt.MouseInfo;
import java.awt.PointerInfo;

public class MouseListener extends MouseAdapter {
   private MyWorld world;
   public static int x = 0;
   public static int y = 0;
   public static int RightClick = 0;
   public static int LeftClick = 0;
   public static PlayableElement moving = null;
   
   public MouseListener (MyWorld w){
      world = w;
   } 
   public void mousePressed(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON3 && moving==null){
         RightClick = 1;
         world.getView().repaint();
      }
      if (e.getButton() == MouseEvent.BUTTON1){
         LeftClick = 1;
         world.getView().repaint();
      }
      /*selectedElement = world.findElement(e.getPoint().getX(), e.getPoint().getY());
      if (selectedElement != null){
      if (selectedElement instanceof Piece){
         selectedElement.setSelected();
         world.getView().repaint();
   }*/
   }
   
   public void mouseDragged(MouseEvent e) {
      x = e.getX();
      y = e.getY();
      world.getView().repaint();
   }
   
   public void mouseMoved(MouseEvent e){
      x = e.getX();
      y = e.getY();
      world.getView().repaint();
   }
   
   public void mouseReleased(MouseEvent e) {
      if (e.getButton() == MouseEvent.BUTTON3){
         RightClick = 0;
      }
      if (e.getButton() == MouseEvent.BUTTON1){
         LeftClick = 0;
      }
   }
}