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

📄 gamehandle.java

📁 java开发的手机游戏 泡泡堂 可以在手机上运行
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
						
								role.btDeathCurrentIndex//死亡动画指向下一指帧在图片的索引值       
	          					= role.nextFrame(role.btDeathTotalFrame,                             
            	    	    	role.btDeathCurrentFrame,                          
                   				role.arr_btDeathAnimationFrame);                   	                        
            		role.paintImage(GameManage.g,
            								role.x,
            								role.y,
            								role.imgDeath,//绘制死亡      
                           	role.btDeathTotalCol,//role.btDeathTotalRow,
                          	role.btDeathTotalRow,//role.btDeathTotalCol,                      
					                	role.btDeathCurrentIndex);                               
								if(role.btDeathCurrentFrame[0] == 4){
										role.nCurrentMsg = Role.MSG_END;
										switch(role.RoleType){								
												case Role.PLAYER:{														
														GameManage.nPlayer1State= GameManage.PLAYER_END;
												}break;
												case Role.COMPUTTER:{
														GameManage.nPlayer2State= GameManage.PLAYER_END;
												}break;
												case Role.COMPUTTER_2:{
														GameManage.nPlayer3State= GameManage.PLAYER_END;
												}break;																											
										}//end switch
								}//end if			
							
						 		GameManage.bIsRoleMsg = false   ;    
						}//end if  						          
				}break;
				
				case Role.MSG_END:{//结束
						
				}break;
     }//end switch


  }//end fun


//泡泡事件处理
  public synchronized  void PaopHandleProcess(Role r,Role c,Role c2,Map m){

    
    	if(((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg <= Bomb.Pop.MSG_SWELL &&
    	bIsPopMove){//泡泡推动测试与动画
    			if(r.RoleType==Role.PLAYER){
    					checkPopMove(r,m);	
    					System.out.println("fffffffffffffffff");
    			}
   	 	}    
      //当人物离开放泡泡的行列,则设置泡泡为碰撞属性
			if(((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg <= Bomb.Pop.MSG_SWELL){
				byte row = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtRow;
				byte col = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtCol;
				if(col != getPutPaopCol(r, m) || row != getPutPaopRow(r, m)){
					m.setLayer(row ,col,(byte)9);//设置人物所在行列为建筑层
				}
			}
			
			
      try{
      //泡泡消息处理
      switch (((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg) {
      
        case Bomb.Pop.MSG_SWELL:{//放泡泡状态
          //System.out.println("Bomb.Pop.MSG_SWELL");
          if( ++r.bomb.nRunTime % 2 == 0){  
          	drawSwell(0,r,m);//画泡泡膨胀
          	if(++((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.iRunTime >=
             	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.iExistTime){//如果到了爆炸的时候
            	//改变成爆炸状态
            	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg = Bomb.Pop.MSG_BLAST;
            	//设置成地面层
            	m.setLayer((((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtRow),
                       	(((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtCol),
                       	(byte)0);           
          	}
          }
        }break;  
        
        case Bomb.Pop.MSG_BLAST:{//爆炸状态
        	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.ix =
        																	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.ix;
        	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iy =
        																	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.iy;
        	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow =
        																	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtRow;
        	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol =
        																	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtCol;
        	
          //System.out.println("Bomb.Pop.MSG_BLAST");
          //泡泡爆炸动画
          drawBlast(0,r,c,c2,m);
          if(++((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iRunTime >=
             ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iExistTime){//如果到了爆炸停止的时候
            //改变成爆炸结束状态
            ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg = Bomb.Pop.MSG_CLEAR;
          }        
        }break;  
        
        case Bomb.Pop.MSG_DEAD:{ //死亡状态
          	//泡泡引起死亡的动画
          	r.bomb.nextBombFrame( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)));
          	r.bomb.paintBomb(GameManage.g,( (Bomb.Pop) r.bomb.popQueue.elementAt(0)));
        }break;
        
        case Bomb.Pop.MSG_CLEAR:{//清除剩余状态
        		((Bomb.Pop)r.bomb.popQueue.elementAt(0)).btCurrentMsg = Bomb.MSG_END;
        			//if(GameCheck.behaviorMsg != Bomb.MSG_END)
            		OperBlastEnd(0, r, m); //清除爆炸残图,恢复地面            	
            	//GameCheck.behaviorMsg = Bomb.MSG_END;
        }break;
        
        case Bomb.Pop.MSG_END:{//结束状态        	        
        }break;
        
      }//end switch

    GameManage.bIsPaopMsg = false;//禁止重画
		}catch(Exception e){
            	System.out.println("error is here:"+e.toString());
            }


  }




  public void drawSwell(int i,Role r,Map m){//画泡泡膨胀
  	
    //画地面
    m.paintFloor(GameManage.g,
                 ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtRow,
                 ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btAtCol);
    r.bomb.nextBombFrame( ((Bomb.Pop) r.bomb.popQueue.elementAt(i)));
    r.bomb.paintImage(GameManage.g,
                      ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.ix,
                      ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.iy,
                      r.bomb.imgSwell,//绘制爆炸
                      r.bomb.btSwellTotalRow,
                      r.bomb.btSwellTotalCol,
                      ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amSwell.btCurrentIndex);

  }


  //更新爆炸坐标
  public void UpdataBlastPosit(int i,Role r,Role c,Role c2,Map m){
		
		
		byte nCurrentFrame =  ((Bomb.Pop) r.bomb.popQueue.elementAt(i)).amBlast.btCurrentFrame[0];//获得爆炸的当前图片序列    
		int row = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow;//当前泡泡所在行
    int col = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol;//当前泡泡所在列
    int rIndex = boobPosit[nCurrentFrame].rIndex;//爆炸图片行的偏移量
    int cIndex = boobPosit[nCurrentFrame].cIndex;//爆炸图片列的偏移量
    
    
    int nCurrentRow = row + rIndex;//当前泡泡爆炸所在行
    int nCurrentCol = col + cIndex;//当前泡泡爆炸所在列
    //求出爆炸坐标
    ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.ix = m.mapPosit[nCurrentRow][nCurrentCol].ix;
    ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iy = m.mapPosit[nCurrentRow][nCurrentCol].iy;
    
    //测试死亡		
    checkDeath(r,m,row+rIndex,col+cIndex);
    checkDeath(c,m,row+rIndex,col+cIndex);
    checkDeath(c2,m,row+rIndex,col+cIndex);
   
  	
  	
	}

	
	public void checkDeath(Role r,Map m,int row,int col){
			
			if(getPutPaopRow(r,m)==row &&
			getPutPaopCol(r,m)==col){
					r.nCurrentMsg = Role.MSG_DEAD;
					switch(r.RoleType){
							case Role.COMPUTTER_2:{
									GameManage.nPlayer3State = GameManage.PLAYER_DEAD;
							}break;
							case Role.COMPUTTER:{
									GameManage.nPlayer2State = GameManage.PLAYER_DEAD;
							}break;
							case Role.PLAYER:{
									GameManage.nPlayer1State = GameManage.PLAYER_DEAD;
							}break;
					}//end switch
			}//end if
			
	}//end fun


	public boolean  isSuperBlast(Role r){
		
		return (((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow ==1 ||//处在边界的泡泡
   					((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 8 ||
  					((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol == 1 ||
  					((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol == 8 );
  }

  //画出爆炸动画
  public void drawBlast(int i,Role r,Role c,Role c2,Map m){//画泡泡爆炸

    r.bomb.nextBombFrame( ((Bomb.Pop) r.bomb.popQueue.elementAt(i)));//确定当前图片
    UpdataBlastPosit(i,r,c,c2,m);//确定贴图坐标
   	
  	if(	isSuperBlast(r) ){			
  		
   			SuperBlast(r,c,c2,m);
   		
   	}else{			
   			r.bomb.paintImage(GameManage.g,//绘图
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.ix,
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iy,
                      	r.bomb.imgBlast,//绘制爆炸
                      	r.bomb.btBalstTotalRow,
                      	r.bomb.btBalstTotalCol,
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btCurrentIndex);			
		}
 
 
 }
	  
  //爆炸结束时的处理
  public void OperBlastEnd(int i,Role r,Map map){
  
    int row = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow;
    int col = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol;
      int boobNum = 5;
      if(!isSuperBlast(r)){//非超强爆破的处理      
        	for (int j = 0; j < boobNum; j++) {         
          		if (map.byBuild[row + boobPosit[j].rIndex]
              [col + boobPosit[j].cIndex] <= 1) {
            			map.paintFloor(GameManage.g,
                  					row + boobPosit[j].rIndex,//当前爆炸图帧的行偏移
                           	col + boobPosit[j].cIndex);//当前爆炸图帧的列偏移
            			map.setLayer(row + boobPosit[j].rIndex,
                  		      col + boobPosit[j].cIndex,
                      	   (byte) - 1);
          		} else {
            			map.paintBuild(GameManage.g,
                           row + boobPosit[j].rIndex,//当前爆炸图帧的行偏移                           
                           col + boobPosit[j].cIndex);//当前爆炸图帧的列偏移
          		}
       	 }
    	}else{//超强爆破的结束处理
    		System.out.println("isSuperBlast");
    		superBlastEnd(r,map);
    	}
	}
	

//强大爆破的结束处理
	public void superBlastEnd(Role r, Map m){
		
		
		byte nCurrentFrame =  
			((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btCurrentFrame[0];//获得爆炸的当前图片序列
		int row = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow;
    int col = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol;
		
		
		
		m.paintFloor(GameManage.g,row,col);//先把中间清除
		//清除1行1列的泡泡
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 1 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol ==1 ){									
						for(int i=2;i<10;i++){//右方向清除:2列到9列长的爆炸
								m.paintFloor(GameManage.g,1,i);
						}		
						for(int i=2;i<10;i++){//下方向清除:2行到9行长的爆炸
								m.paintFloor(GameManage.g,i,1);                           	
						}
		}
		
		
		//清除1行9列的泡泡
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 1 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol ==8 ){																							
						for(int i=7;i>0;i--){//左方向清除:7列到1列长的爆炸
								m.paintFloor(GameManage.g,1,i);
						}						
						for(int i=2;i<10;i++){//下方向清除:2行到9行长的爆炸
								m.paintFloor(GameManage.g,i,8);								
						}									
		}		
		
				
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 8 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol == 8 ){//99的泡泡						
						for(int i=7;i>0;i--){//左方向清除:7列到1列长的爆炸
								m.paintFloor(GameManage.g,8,i);
						}		
						for(int i=7;i>0;i--){//上方向清除:7行到1行长的爆炸
								m.paintFloor(GameManage.g,i,8);
						}										
		}	
		
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 8 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol == 1 ){//81的泡泡						
						for(int i=7;i>0;i--){//上方向清除:7行到1行长的爆炸
								m.paintFloor(GameManage.g,i,1);
						}					
						for(int i=1;i<10;i++){//7列到1列长的爆炸
								m.paintFloor(GameManage.g,8,i);
						}										
		}
		
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol != 1 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol != 8 ){//up down的泡泡
						System.out.println("up down111111111");								
						for(int i=col-1;i>0;i--){//7列到1列长的爆炸
								m.paintFloor(GameManage.g,row,i);
						}												
						if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow != 1 &&
						m.byBuild[row-1][col]<=1){//设置为地面层
								m.byBuild[row-1][col]=0;
						}
						m.paintFloor(GameManage.g,row-1,col);						//需要加判断
						for(int i=col+1;i<10;i++){//7列到1列长的爆炸
								m.paintFloor(GameManage.g,row,i);
						}	
						if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow != 8 &&
						m.byBuild[row+1][col]<=1){//设置为地面层
								m.byBuild[row+1][col]=0;
						}						
						m.paintFloor(GameManage.g,row+1,col);						//需要加判断																
		}	
			
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow != 8 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow != 1 ){//left right的泡泡						
						if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol != 1 &&
						m.byBuild[row][col-1]<=1){
								m.byBuild[row][col-1]=0;
						}
						m.paintFloor(GameManage.g,row,col-1);																				
						for(int i=row-1;i>0;i--){//7列到1列长的爆炸
								m.paintFloor(GameManage.g,i,col);
						}						
						if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol != 8 &&
						m.byBuild[row][col+1]<=1){
							m.byBuild[row][col+1]=0;
						}
						m.paintFloor(GameManage.g,row,col+1);																
						for(int i=row+1;i<9;i++){//7列到1列长的爆炸
								m.paintFloor(GameManage.g,i,col);		
						}												
		}
		
	
	}


	//强大爆破效果
	public void SuperBlast(Role r, Role c, Role c2, Map m){
		
		
		byte nCurrentFrame =  
			((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btCurrentFrame[0];//获得爆炸的当前图片序列
		int row = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtRow;
    int col = ((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btAtCol;
		
		//1行1列的泡泡
		if( ((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtRow == 1 &&
		((Bomb.Pop) r.bomb.popQueue.elementAt(0)).amBlast.btAtCol ==1 ){
			System.out.println("11 pop");
				switch( nCurrentFrame ){
						case 0:{
								r.bomb.paintImage(GameManage.g,//绘图
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.ix,
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.iy,
                      	r.bomb.imgBlast,//绘制爆炸
                      	r.bomb.btBalstTotalRow,
                      	r.bomb.btBalstTotalCol,
                      	((Bomb.Pop)r.bomb.popQueue.elementAt(0)).amBlast.btCurrentIndex);

⌨️ 快捷键说明

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