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

📄 bullet.java

📁 这是一款竖版射击手机游戏
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                        Play_Rocket[i][8] = 3;
                        break;
                }
                Play_Rocket[i][7] = 1;
            }
        }
    }
    
    /**
     *更新玩家子弹的坐标
     *@parameter play_sort:标志是玩家的弓箭还是跟随者的弓箭
     */
    public void update_bullet_point(int yview,int play_sort){
        for(int i = 0 ; i<PLAY_BULLET_NUM;i++){
            if(play_bullet[i][4] == 1){
                if(play_bullet[i][11] == play_sort){
                    play_bullet[i][0] +=play_bullet[i][3];
                    play_bullet[i][1] +=play_bullet[i][2];
                }
                int temX = (play_bullet[i][0] - play_bullet[i][5]);
                int temY = (play_bullet[i][1] - play_bullet[i][6]);
                if(((temX * temX + temY * temY) > (hero_play.hero_property[2] * hero_play.hero_property[2]) && hero_play.hero_property[1]!=1) || ((temX * temX + temY * temY) > (hero_play.hero_property[2] * hero_play.hero_property[2]) && hero_play.hero_property[22]==0 && hero_play.hero_property[9]==1)
                || play_bullet[i][0] < 0 || play_bullet[i][0] > 176 || play_bullet[i][1] < yview || play_bullet[i][1] > yview + 208){
                    play_bullet[i][4] = 0;
                    play_bullet[i][7] = 0;
                    play_bullet[i][8] = 0;
                    play_bullet[i][9] = 0;
                    play_bullet[i][10] = 0;
                    play_bullet[i][13] = 0;
                    play_bullet[i][14] = 0;
                }
            }
        }
    }
    /**
     *更新玩家火箭的坐标
     */
    public int[] update_rocket_bullet_point(int yview){
        int[] tem_xy ={0,0};
        for(int i = 0;i<3;i++){
            if(Play_Rocket[i][4]==1 && Play_Rocket[i][7] == 1){
                Play_Rocket[i][0] +=Play_Rocket[i][3];
                Play_Rocket[i][1] +=Play_Rocket[i][2];
                int tem_x = (Play_Rocket[i][0] - Play_Rocket[i][5]);
                int tem_y = (Play_Rocket[i][1] - Play_Rocket[i][6]);
                if((tem_x * tem_x + tem_y * tem_y) > (100 * 100) || Play_Rocket[i][0] < 0 || Play_Rocket[i][0] > 176 || Play_Rocket[i][1] < yview || Play_Rocket[i][1] > yview + 208){
                    Play_Rocket[i][4] = 0;
                    Play_Rocket[i][7] = 0;
                    Play_Rocket[i][8] = 0;
                    x = Play_Rocket[i][0];
                    y = Play_Rocket[i][1];
                    is_explosion = true;
                    tem_xy[0] = Play_Rocket[i][0];
                    tem_xy[1] = Play_Rocket[i][1];
                    explosion_start = System.currentTimeMillis();
                    return tem_xy;
                }
            }
        }
        return tem_xy;
    }
    public void explosion_impact(){
        int id=0 ;
        if(System.currentTimeMillis() - explosion_start > explosion[explosion_i*2+1]){
            explosion_i++;
            if(explosion_i>3){
                explosion_i=0;
                is_explosion = false;
            }
            id = explosion[explosion_i*2];
            x1 = this.play_explosion[id*4];
            y1 = play_explosion[id*4+1];
            w = play_explosion[id*4+2];
            h = play_explosion[id*4+3];
            explosion_start = System.currentTimeMillis();
        }
    }
    public void draw(Graphics g,Image img){
        if(is_explosion){
            explosion_impact();
            try{
                g.setClip(x,y,w,h);//画小图片
                g.drawImage(img,x-x1,y-y1,Graphics.LEFT|Graphics.TOP);//画大图片
                g.setClip(0, 0, 176, 208);
            }catch (Exception e) {}
        }
    }
    /**
     *画玩家子弹
     */
    public void draw_bullet(Graphics g ,int yview){//,Image image2
        for(int i=0;i<PLAY_BULLET_NUM;i++){
            if(play_bullet[i][4] == 1 && play_bullet[i][7]==1){
                if(play_bullet[i][11]==1){//玩家弓箭
                    if(hero_play.hero_property[1]==1){
                        X = arrowimgdata[(play_bullet[i][8]+2)*4];
                        Y = arrowimgdata[(play_bullet[i][8]+2)*4+1];
                        w1 = arrowimgdata[(play_bullet[i][8]+2)*4+2];
                        h1 = arrowimgdata[(play_bullet[i][8]+2)*4+3];
                    }else{
                        X = arrowimgdata[(play_bullet[i][8]-1)*4];
                        Y = arrowimgdata[(play_bullet[i][8]-1)*4+1];
                        w1 = arrowimgdata[(play_bullet[i][8]-1)*4+2];
                        h1 = arrowimgdata[(play_bullet[i][8]-1)*4+3];
                    }
                }else{//跟随者弓箭
                    X = arrowimgdata[(play_bullet[i][8]-1)*4];
                    Y = arrowimgdata[(play_bullet[i][8]-1)*4+1];
                    w1 = arrowimgdata[(play_bullet[i][8]-1)*4+2];
                    h1 = arrowimgdata[(play_bullet[i][8]-1)*4+3];
                }
//                if(play_bullet[i][9] == 0 || play_bullet[i][10] == 0){//赋值
//                    play_bullet[i][9] = w1;
//                    play_bullet[i][10] = h1;
//                }
                try{
                    g.setClip(play_bullet[i][0],play_bullet[i][1],w1,h1);//画小图片
                    g.drawImage(FlyGenCavans.Game_Arrow,play_bullet[i][0]-X,play_bullet[i][1]-Y,Graphics.LEFT|Graphics.TOP);//画大图片
                    g.setClip(0, 0, 176, 208);
                }catch (Exception e) {}
            }
        }
    }
    /**
     *画玩家火箭
     */
    public void draw_rocket_bullet(Graphics g,int yview){
        for(int i = 0;i<3;i++){
            if(Play_Rocket[i][4] == 1){
                
                X = arrowimgdata[(Play_Rocket[i][8]+5)*4];
                Y = arrowimgdata[(Play_Rocket[i][8]+5)*4+1];
                w1 = arrowimgdata[(Play_Rocket[i][8]+5)*4+2];
                h1 = arrowimgdata[(Play_Rocket[i][8]+5)*4+3];
                
                if(Play_Rocket[i][9] == 0 || Play_Rocket[i][10] == 0){
                    Play_Rocket[i][9] = w1;
                    Play_Rocket[i][10] = h1;
                }
                try{
                    g.setClip(Play_Rocket[i][0],Play_Rocket[i][1],w1,h1);//画小图片
                    g.drawImage(FlyGenCavans.Game_Arrow,Play_Rocket[i][0]-X,Play_Rocket[i][1]-Y,Graphics.LEFT|Graphics.TOP);//画大图片
                    g.setClip(0, 0, 176, 208);
                }catch (Exception e) {}
                //g.drawImage(image1[Play_Rocket[i][8]-1], Play_Rocket[i][0], Play_Rocket[i][1], Graphics.TOP|Graphics.LEFT);
            }
        }
    }
    
    /**
     *检测是否对敌人造成伤害
     *@parameter
     *Foe foe 攻击的敌人
     */
    public void check_attack_foe(Foe foe){
        for(int i=0;i<PLAY_BULLET_NUM;i++){
            if(play_bullet[i][4] == 1 && play_bullet[i][7]==1){
                if(MapTool.isIntersectingRect(play_bullet[i][0]+play_bullet[i][13], play_bullet[i][1]+play_bullet[i][14], play_bullet[i][9], play_bullet[i][10], foe.getX(), foe.getY(), foe.getWidth(), foe.getHeight())){
                    foe.foe_property[2]-=this.hero_play.hero_property[3];
                    if(hero_play.hero_property[1]!=1 || play_bullet[i][11]==2){
                        play_bullet[i][4] = 0;
                        play_bullet[i][7] = 0;
                        play_bullet[i][8] = 0;
                        play_bullet[i][9] = 0;
                        play_bullet[i][10] = 0;
                        play_bullet[i][13] = 0;
                        play_bullet[i][14] = 0;
                    }
                }
            }
        }
    }
    
    /**
     *设置精灵子弹的原始坐标
     *@parameter foe_sort 为精灵的类型.X,Y子弹的起始坐标.foe_sort 精灵的类型
     * bullet_range 为此类种类型的精灵的射程.attack_strength 为此种类型的精灵的攻击力
     */
    public void set_foe_bullet_point(int x ,int y,int foe_sort,int bullet_range,int attack_strength){
        boolean tem1=false;
        int tem_num = 3;
        for(int i=0;i<FOE_BULLET_NUM;i++){
            if(foe_sort == 11 || foe_sort ==3){//3发子弹foe_sort==3 ||
                //System.out.println("当前的弓箭类型:"+foe_sort+"----当前为第"+i+"发子弹");
                if(foe_bullet[i][4] == 0 && tem_num > 0){
                    foe_bullet[i][0] = x;
                    foe_bullet[i][1] = y;
                    foe_bullet[i][5] = x;
                    foe_bullet[i][6] = y;
                    foe_bullet[i][4] = 1;
                    foe_bullet[i][11] = foe_sort;
                    foe_bullet[i][12] = bullet_range;
                    tem_num--;
                }
            } else{//单发
                if(foe_bullet[i][4] != 1 && tem_num > 0){
                    foe_bullet[i][0] = x;
                    foe_bullet[i][1] = y;
                    foe_bullet[i][5] = x;
                    foe_bullet[i][6] = y;
                    foe_bullet[i][4] = 1;
                    foe_bullet[i][11] = foe_sort;
                    foe_bullet[i][12] = bullet_range;
                    tem_num = tem_num - 3;
                }
            }
            foe_bullet[i][15] = attack_strength;
        }
    }
    /**
     *设置精灵子弹的速度
     *@parameter foe_sort 为精灵的类型,foe_face_direction 为精灵的当前面向,foe_speed 为精灵弓箭的速度
     */
    public void set_foe_bullet_speed(int foe_sort,int foe_face_direction,int foe_speed){
        int direction_num=0;
        int bullet_direction = 0;
        int[] arc_num_x  = {
            -7071,0,7071,//向下的
                    -10000,-7071,0,//向左下的
                    0,7071,10000//向右下的
        };
        int[] arc_num_y ={
            7071,10000,7071,//向下的
                    0,7071,10000,//向左下的
                    10000,7071,0//向右下的
        };
        for(int i = 0;i<FOE_BULLET_NUM;i++){
            if(direction_num >=3)
                direction_num = 0;
            if(foe_bullet[i][4] == 1 && foe_bullet[i][7] !=1){
                if(foe_sort == 11 || foe_sort ==3){//千骑长的攻击foe_sprite.foe_property[1];这里可以用foe_bullet[i][11]来代替精灵的类型foe_sort == 3 ||
                    switch(foe_face_direction){
                        case 2://向下发
                            bullet_direction = 0;
                            if(direction_num ==0)
                                foe_bullet[i][8] = 1;

⌨️ 快捷键说明

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