Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static boolean isHit(int left1, int top1, int w1, int h1, int left2, int top2, int w2, int h2) {
        int x1 = left1 + w1 / 2;
        int y1 = top1 + h1 / 2;
        int x2 = left2 + w2 / 2;
        int y2 = top2 + h2 / 2;
        if (Math.abs(x1 - x2) < (w1 / 2 + w2 / 2) - 10 && Math.abs(y1 - y2) < (h1 / 2 + h2 / 2) - 10) {
            return true;
        }
        return false;
    }
}