boom.java

来自「手机上Java小游戏——深水炸弹」· Java 代码 · 共 71 行

JAVA
71
字号
package qian;

import javax.microedition.lcdui.*;
import java.util.*;

public class Boom {
  static Image img;
  int x;
  int y;
  Graphics b;
  private Ship sp;

  static {
    try {

      img = Image.createImage("/res/boom.png");

    }
    catch (Exception e) {
    }

  }

  public Boom(Ship sp) {
    this.sp = sp;

    x = sp.Xputter();
    y = sp.Yputter();

  }

  public void paint(Graphics g) {
    g.drawImage(img, x, y, Graphics.TOP | Graphics.LEFT);
  }

  public boolean crash(QianTing qt) {

    if ( (this.x + this.img.getWidth()) > qt.Qxputter() &&
        (this.x + this.img.getWidth()) < (qt.Qxputter() + qt.pic1.getWidth()) &&
        (this.y + this.img.getHeight()) > qt.Qyputter() &&
        (this.y + this.img.getHeight()) < (qt.Qyputter() + qt.pic1.getHeight())) {
      return true;
    }

    if ( (this.x) > qt.Qxputter() &&
        (this.x) < (qt.Qxputter() + qt.pic1.getWidth()) &&
        (this.y + this.img.getHeight()) > qt.Qyputter() &&
        (this.y + this.img.getHeight()) < (qt.Qyputter() + qt.pic1.getHeight())) {
      return true;
    }

    if ( (this.x + this.img.getWidth()) > qt.Qxputter() &&
        (this.x + this.img.getWidth()) < (qt.Qxputter() + qt.pic1.getWidth()) &&
        (this.y) > qt.Qyputter() &&
        (this.y) < (qt.Qyputter() + qt.pic1.getHeight())) {
      return true;
    }

    if ( (this.x) > qt.Qxputter() &&
        (this.x) < (qt.Qxputter() + qt.pic1.getWidth()) &&
        (this.y) > qt.Qyputter() &&
        (this.y) < (qt.Qyputter() + qt.pic1.getHeight())) {
      return true;
    }

    return false;

  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?