⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enemybullet.java

📁 用java做的和雷电游戏相似的一个小游戏,不过里面还有好多需要改进的地方.
💻 JAVA
字号:
package lightning;

public class EnemyBullet {
  int x;
  int y;
  int vx;
  int cont;
  int vy;
  boolean islive=true;
  EnemyBullet(int x,int y,int a,int b) {
    this.x=x;
    this.y=y;
    this.vy=15;
    this.cont=0;
    if(this.x<a){
      this.vx=2;
    }
    else{
      this.vx=-2;
    }
    if(this.y<b){
      this.vy=7;
    }
    else{
      this.vy=-7;
    }
  }
  public void move(){
    if(this.cont>=20){
      this.cont=0;
    }
    this.cont++;
    this.y+=this.vy;
    this.x+=this.vx;
  }
  public void hit(int a,int b){
    if(Math.abs((x+10)-(a+25))<28 && Math.abs((y+10)-(b+5))<28){
      this.islive=false;
    }
    else{
      this.islive=true;
    }
  }
/*	public void hitblast(int c,int d){
    if(Math.abs((x+10)-(c+200))<1 && Math.abs((y+10)-(d+200))<1){
      this.islive=false;
    }
    else{
      this.islive=true;
    }
  }*/
}

⌨️ 快捷键说明

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