/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Game;

import java.awt.Insets;
import java.awt.Point;
import javaPlay.GameEngine;
import javaPlay.Mouse;
import javaPlay.Sprite;

/**
 *
 * @author Jose Ricardo
 */
public class MenuItem extends RenderableGameEntitie{
    private int id;

    public int getId() {
        return id;
    }

    

    public MenuItem(String filename, int width, int height, int id) {
        this.width = width;
        this.height = height;
        this.id = id;
        sprite = new Sprite(filename, 1, width, height);
    }


    @Override
    public void step(long timeElapsed) {        
    }

    public boolean isSelected(){
        Mouse mouse = GameEngine.getInstance().getMouse();

        if (mouse.isLeftButtonPressed() == true){
            Point cursorPos = mouse.getMousePos();

            // Ajustar posicao para levar em conta as bordas da janela
            Insets insets = GameEngine.getInstance().getGameCanvas().getInsets();
            int xoffset = insets.left + insets.right;
            int yoffset = insets.top + insets.bottom;

            cursorPos.x -= xoffset;
            cursorPos.y -= yoffset;

            if (cursorPos.x > x && cursorPos.x < (x + width) &&
                    cursorPos.y > y && cursorPos.y < (y + height))
                return true;
        }

        return false;
    }
}
