boom2.java

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

JAVA
54
字号
package qian;

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

public class Boom2 {
  static Image img;
  int x;
  int y;
  Graphics b;


  static {
    try {

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

    }
    catch (Exception e) {
    }

  }

  public Boom2(int xx,int yy) {
   this.x=xx;
   this.y=yy;
  }

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

  public boolean crash(Ship ship) {

    if ( (this.x + this.img.getWidth()) > ship.x &&
        (this.x + this.img.getWidth()) < (ship.x + ship.imgLeft.getWidth()) &&
        (this.y) > ship.y&&
        (this.y) < (ship.y + ship.imgLeft.getHeight())) {
      return true;
    }

    if ( (this.x) > ship.x &&
        (this.x) < (ship.x + ship.imgLeft.getWidth()) &&
        (this.y) > ship.y &&
        (this.y) < (ship.y + ship.imgLeft.getHeight())) {
      return true;
    }

    return false;

  }

}

⌨️ 快捷键说明

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