

import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.MouseInfo;
import java.awt.Color;

   
public class Player {

   int x,y=0;
   private static final int WIDTH = 30;
   private static final int HEIGHT = 30;
 
   private Game game;

   public Player(Game game) {
      this.game = game;
   }

   public void paint(Graphics2D g) {
   
        
      if(MouseInfo.getPointerInfo().getLocation().x<game.getWidth()-WIDTH){
         x=MouseInfo.getPointerInfo().getLocation().x;
      } 
      else x=game.getWidth()-WIDTH;
   
      if(MouseInfo.getPointerInfo().getLocation().y< game.getHeight()-HEIGHT-HEIGHT) {
         y=MouseInfo.getPointerInfo().getLocation().y;
      }
      else y=game.getWidth()-HEIGHT-HEIGHT;
       
      g.setColor(Color.black);
      g.fillRect(x,y,WIDTH,HEIGHT);
      
   }

   public Rectangle getBounds() {
      return new Rectangle(x, y, WIDTH, HEIGHT);      
   }
   
}