///!Button Script!///

package com.example.j9.triqshot;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.CountDownTimer;
import android.view.MotionEvent;

import static android.view.MotionEvent.ACTION_DOWN;

public class Buttons{
//Button Size
public int width;
public int height;

//Button Position
public long X;
public long Y;

//Button Image
private Bitmap image;

//Button Constructor
public Buttons( int X, int Y, int width, int height, Bitmap image){
   this.X = X;
   this.Y = Y;
   this.width = width;
   this.height = height;
   this.image = Bitmap.createScaledBitmap(image, width, height, false);
  }

//Button Graphics
public void draw(Canvas canvas){
   canvas.drawBitmap(image, X, Y, null);
  }

//Set button visuals
public void setImage(Bitmap IMG){
   image = IMG;
   image = Bitmap.createScaledBitmap(image, width, height, false);
  }

//Check if the button is hit
public boolean isPressed(MotionEvent event){
   float MouseX = event.getX();
   float MouseY = event.getY();
  
   if(MouseX >= X && MouseX <= (X + width)){
    if(MouseY >= Y && MouseY <= (Y + height)){
     if(event.getActionMasked() == ACTION_DOWN) {
      return true;
     }
    }
   }
   return false;
  }

}

///!LevelButton Script!///

package com.example.j9.triqshot;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.support.v7.widget.AppCompatImageButton;
import android.util.AttributeSet;

public class LevelButton extends Buttons{
//LevelButton ID
public int ID;

//LevelButton Constructor
public LevelButton( int X, int Y, int width, int height, Bitmap image){
   super(X, Y, width, height, image);
  }

}