最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

java實(shí)現(xiàn)抖音飛機(jī)大作戰(zhàn)

 更新時(shí)間:2020年11月19日 09:01:10   作者:qq_39437613  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)抖音飛機(jī)大作戰(zhàn),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java抖音飛機(jī)大作戰(zhàn)的具體代碼,供大家參考,具體內(nèi)容如下

Airplane.java

package zmf.game.shoot;
import java.util.Random;

/**
 * @author jcf
 * @Description: Airplane----敵機(jī)既是飛行物
 * @date 2018-03-28 11:17:16
 */
public class Airplane extends FlyingObject implements Enemy{
 /** 敵機(jī)走步的步數(shù) **/
 private int speed = 2;
 public Airplane(){
 image = ShootGame.airplane;
 width = image.getWidth();
 height = image.getHeight();
 Random rand = new Random();
 x = rand.nextInt(ShootGame.WIDTH - this.width);
 //y:負(fù)的敵機(jī)的高
 y = -this.height;
 
 
 }
 
 @Override
 public int getScore(){
 return 5;
 }

 @Override
 public void step(){
 y += speed;
 }

 /**
 * 是否越界
 * @return
 */
 @Override
 public boolean outOfBounds(){
 //敵機(jī)的y坐標(biāo)大于窗口的高
 return this.y > ShootGame.HEIGHT;
 
 }

}

FlyingObject.java

package zmf.game.shoot;
import java.awt.image.BufferedImage;

/**
 * @author jcf
 * @Description: 飛行物主類(lèi)
 * @date 2018-03-28 11:17:16
 */
public abstract class FlyingObject {
 /** 圖片命名--java包自有的 **/
 protected BufferedImage image;
 /** 寬 **/
 protected int width;
 /** 高 **/
 protected int height;
 /** x坐標(biāo) **/
 protected int x;
 /** y坐標(biāo) **/
 protected int y;

 /**
 * 飛行物走步
 */
 public abstract void step();

 /**
 * 是否越界
 * @return
 */
 public abstract boolean outOfBounds();

 /**
 * 敵人被子彈撞
 * @param bullet
 * @return
 */
 public boolean shootBy(Bullet bullet){
 //this:敵人 other:子彈
 int x1 = this.x;
 int x2 = this.x + this.width;
 int y1 = this.y;
 int y2 = this.y + this.height;
 int x = bullet.x;
 int y = bullet.y;
 return x > x1 && x < x2
 &&
 y > y1 && y < y2;
 }
 
}

完整源碼下載地址:飛機(jī)大作戰(zhàn)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

姚安县| 潜江市| 东城区| 当雄县| 远安县| 比如县| 许昌市| 崇左市| 上虞市| 兴安县| 武陟县| 惠安县| 从化市| 湘潭市| 炎陵县| 高陵县| 舞钢市| 噶尔县| 宝山区| 当阳市| 澎湖县| 永宁县| 钦州市| 繁峙县| 德清县| 宝山区| 九寨沟县| 海原县| 屯留县| 太仓市| 遵义县| 新邵县| 九龙城区| 玛曲县| 潢川县| 伊金霍洛旗| 烟台市| 阳原县| 天等县| 名山县| 阿鲁科尔沁旗|