热门标签 | HotTags
当前位置:  开发笔记 > Android > 正文

android自定义view实现推箱子小游戏

这篇文章主要为大家详细介绍了android自定义view实现推箱子小游戏,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了android推箱子游戏的具体实现代码,供大家参考,具体内容如下

自定义view:

package com.jisai.materialdesigndemo.tuixiangzhi; 
 
import android.content.Context; 
import android.graphics.Bitmap; 
import android.graphics.BitmapFactory; 
import android.graphics.Canvas; 
import android.graphics.Color; 
import android.graphics.Paint; 
import android.graphics.Rect; 
import android.util.AttributeSet; 
import android.util.Log; 
import android.widget.ImageView; 
 
import com.jisai.materialdesigndemo.R; 
 
import java.util.ArrayList; 
 
public class View_tuixiangzhi extends ImageView { 
  ArrayList arrayList = new ArrayList<>(); 
  int[][][] ccc =new int[300][15][15]; 
  int kk=0; 
  Canvas canvas; 
  private int mWidth; 
  private int mHeight; 
  Boolean flag=false; 
  Bitmap bitmap0= BitmapFactory.decodeResource(getResources(), R.mipmap.qiang); 
  Bitmap bitmap1= BitmapFactory.decodeResource(getResources(),R.mipmap.kong); 
  Bitmap bitmap2= BitmapFactory.decodeResource(getResources(),R.mipmap.ren_1); 
  Bitmap bitmap3= BitmapFactory.decodeResource(getResources(),R.mipmap.xiang_1); 
  Bitmap bitmap4= BitmapFactory.decodeResource(getResources(),R.mipmap.xiang_2); 
  Bitmap bitmap5= BitmapFactory.decodeResource(getResources(),R.mipmap.hua); 
  Bitmap bitmap6= BitmapFactory.decodeResource(getResources(),R.mipmap.renandhua); 
  int [][]aaa= {//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,5,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,3,1,3,5,0,0,0,0,0}, 
      {0,0,0,0,5,3,2,1,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,3,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,5,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
      {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
  }; 
 
  public interface PassLitener 
  { 
    void pass(); 
  } 
  private PassLitener mPassLitener; 
  public void setPassLitener(PassLitener mPassLitener) 
  { 
    this.mPassLitener = mPassLitener; 
  } 
 
  public View_tuixiangzhi(Context context) { 
    super(context); 
    init("MyImageView(Context context)"); 
  } 
 
  public View_tuixiangzhi(Context context, AttributeSet attrs) { 
    super(context, attrs); 
    init("MyImageView(Context context, AttributeSet attrs)"); 
  } 
 
  public View_tuixiangzhi(Context context, AttributeSet attrs, int defStyle) { 
    super(context, attrs, defStyle); 
    init("MyImageView(Context context, AttributeSet attrs, int defStyle)"); 
 
  } 
 
  private void init(String structName) { 
  } 
 
  @Override 
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 
    int specSize = MeasureSpec.getSize(widthMeasureSpec); 
 
    mWidth = specSize; 
    specSize = MeasureSpec.getSize(heightMeasureSpec); 
 
    mHeight = specSize; 
 
    Log.e("宽高:","宽:"+mWidth+"高:"+mHeight); 
 
    setMeasuredDimension(mWidth, mHeight); 
 
  } 
 
  @Override 
  protected void onDraw(Canvas canvas) { 
    Log.e("onDraw:","onDraw"); 
    this.canvas=canvas; 
    super.onDraw(canvas); 
    Paint p=new Paint(); 
    p.setColor(Color.RED); 
    //canvas.drawRect(20,20,100,100,p); 
    //canvas.drawColor(Color.RED); 
    for(int i=0;i<15;i++){ 
      for(int k=0;k<15;k++){ 
        int x=aaa[i][k]; 
 
        Rect rect = new Rect((mWidth/15)*k,(mWidth/15)*i,(mWidth/15)*(k+1),(mWidth/15)*(i+1)); 
        switch (x){ 
          case 0: 
            canvas.drawBitmap(bitmap0,null,rect,p); 
            break; 
          case 1: 
            canvas.drawBitmap(bitmap1,null,rect,p); 
            break; 
          case 2: 
            canvas.drawBitmap(bitmap2,null,rect,p); 
            break; 
          case 3: 
            canvas.drawBitmap(bitmap3,null,rect,p); 
            break; 
          case 4: 
            canvas.drawBitmap(bitmap4,null,rect,p); 
            break; 
          case 5: 
            canvas.drawBitmap(bitmap5,null,rect,p); 
            break; 
          case 6: 
            canvas.drawBitmap(bitmap6,null,rect,p); 
            break; 
 
        } 
      } 
    } 
 
 
 
  } 
 
  public void setaaa(int [][]xxx){ 
    for(int i=0;i<15;i++){ 
      for(int k=0;k<15;k++) { 
        aaa[i][k]=xxx[i][k]; 
      } 
    } 
    kk=0; 
    arrayList.clear(); 
    postInvalidate(); 
  } 
  public void moveLeft(){ 
    addBack(); 
    flag=false; 
    for(int i=0;i<15;i++){ 
      if (flag){ 
        break; 
      } 
      for(int k=0;k<15;k++) { 
        if (flag){ 
          break; 
        } 
        int x = aaa[i][k]; 
        if(x==2|x==6){ 
          Log.e("x",""+x+"i:"+i+"k:"+k); 
 
          switch ( aaa[i][k-1]){ 
            case 0://左边是墙,不能移动 
              break; 
            case 1://左边是空,可以移动 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i][k-1]=2; 
 
              break; 
            case 3://左边是空箱子 
              if(aaa[i][k-2]==5){//箱子左边是花 
                aaa[i][k-2]=4; 
                aaa[i][k-1]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
 
              }else if(aaa[i][k-2]==1){//箱子左边是空 
                aaa[i][k-2]=3; 
                aaa[i][k-1]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
 
              }else{}//是其他则不能移动 
 
              break; 
            case 4://左边是满箱子 
              if(aaa[i][k-2]==5){//箱子左边是花 
                aaa[i][k-2]=4; 
                aaa[i][k-1]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
 
              }else if(aaa[i][k-2]==1){//箱子左边是空 
                aaa[i][k-2]=3; 
                aaa[i][k-1]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
 
              }else{}//是其他则不能移动 
              break; 
            case 5://左边是花 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i][k-1]=6; 
 
              break; 
          } 
          flag=true; 
        } 
      } 
    } 
 
 
    postInvalidate(); 
    ifPass(); 
  } 
  public void moveRight(){ 
    addBack(); 
    flag=false; 
    for(int i=0;i<15;i++){ 
      if (flag){ 
        break; 
      } 
      for(int k=0;k<15;k++) { 
        int x = aaa[i][k]; 
        if (flag){ 
          break; 
        } 
        if(x==2|x==6){ 
          Log.e("x",""+x+"i:"+i+"k:"+k); 
          switch ( aaa[i][k+1]){ 
            case 0://右边是墙,不能移动 
              break; 
            case 1://右边是空,可以移动 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i][k+1]=2; 
              break; 
            case 3://右边是空箱子 
              if(aaa[i][k+2]==5){//箱子右边是花 
                aaa[i][k+2]=4; 
                aaa[i][k+1]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i][k+2]==1){//箱子右边是空 
                aaa[i][k+2]=3; 
                aaa[i][k+1]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 4://右边是满箱子 
              if(aaa[i][k+2]==5){//箱子右边是花 
                aaa[i][k+2]=4; 
                aaa[i][k+1]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i][k+2]==1){//箱子右边是空 
                aaa[i][k+2]=3; 
                aaa[i][k+1]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 5://右边是花 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i][k+1]=6; 
              break; 
          } 
          flag=true; 
        } 
      } 
    } 
 
    postInvalidate(); 
    ifPass(); 
  } 
  public void moveUp(){ 
    addBack(); 
    flag=false; 
    for(int i=0;i<15;i++){ 
      if (flag){ 
        break; 
      } 
      for(int k=0;k<15;k++) { 
        int x = aaa[i][k]; 
        if (flag){ 
          break; 
        } 
        if(x==2|x==6){ 
          Log.e("x",""+x+"i:"+i+"k:"+k); 
          switch ( aaa[i-1][k]){ 
            case 0://上边是墙,不能移动 
              break; 
            case 1://上边是空,可以移动 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i-1][k]=2; 
              break; 
            case 3://上边是空箱子 
              if(aaa[i-2][k]==5){//箱子上边是花 
                aaa[i-2][k]=4; 
                aaa[i-1][k]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i-2][k]==1){//箱子上边是空 
                aaa[i-2][k]=3; 
                aaa[i-1][k]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 4://上边是满箱子 
              if(aaa[i-2][k]==5){//箱子上边是花 
                aaa[i-2][k]=4; 
                aaa[i-1][k]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i-2][k]==1){//箱子上边是空 
                aaa[i-2][k]=3; 
                aaa[i-1][k]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 5://上边是花 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i-1][k]=6; 
              break; 
          } 
          flag=true; 
        } 
      } 
    } 
 
    postInvalidate(); 
    ifPass(); 
  } 
  public void moveDown(){ 
    addBack(); 
    flag=false; 
    for(int i=0;i<15;i++){ 
      if (flag){ 
        break; 
      } 
      for(int k=0;k<15;k++) { 
        int x = aaa[i][k]; 
        if (flag){ 
          break; 
        } 
        if(x==2|x==6){ 
          Log.e("x",""+x+"i:"+i+"k:"+k); 
          switch ( aaa[i+1][k]){ 
            case 0://下边是墙,不能移动 
              break; 
            case 1://下边是空,可以移动 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i+1][k]=2; 
              break; 
            case 3://下边是空箱子 
              if(aaa[i+2][k]==5){//箱子下边是花 
                aaa[i+2][k]=4; 
                aaa[i+1][k]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i+2][k]==1){//箱子下边是空 
                aaa[i+2][k]=3; 
                aaa[i+1][k]=2; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 4://下边是满箱子 
              if(aaa[i+2][k]==5){//箱子下边是花 
                aaa[i+2][k]=4; 
                aaa[i+1][k]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else if(aaa[i+2][k]==1){//箱子下边是空 
                aaa[i+2][k]=3; 
                aaa[i+1][k]=6; 
                if(x==6){ 
                  aaa[i][k]=5; 
                }else{ 
                  aaa[i][k]=1; 
                } 
              }else{}//是其他则不能移动 
              break; 
            case 5://下边是花 
              if(x==6){ 
                aaa[i][k]=5; 
              }else{ 
                aaa[i][k]=1; 
              } 
              aaa[i+1][k]=6; 
              break; 
          } 
          flag=true; 
        } 
      } 
    } 
    postInvalidate(); 
    ifPass(); 
  } 
 
  public void ifPass(){ 
    flag=false; 
    for(int i=0;i<15;i++){ 
      if (flag){ 
        break; 
      } 
      for(int k=0;k<15;k++) { 
        int x = aaa[i][k]; 
        if (flag){ 
          break; 
        } 
        if(x==3){//还有空箱子 
          flag=true; 
        } 
      } 
    } 
 
    if (!flag){//没有一个空箱子 
      mPassLitener.pass(); 
    } 
  } 
 
  public void moveBack(){ 
    if(arrayList.size()>0){ 
      this.aaa=(arrayList.get(arrayList.size()-1)); 
      postInvalidate(); 
      arrayList.remove(arrayList.size()-1); 
    } 
  } 
  public void addBack(){ 
    if(kk>299){ 
      arrayList.clear(); 
      kk=0; 
    } 
    if(arrayList.size()>99){ 
      arrayList.remove(0); 
    } 
    for(int i=0;i<15;i++){ 
      for(int k=0;k<15;k++){ 
        ccc[kk][i][k]=aaa[i][k]; 
      } 
    } 
    arrayList.add(ccc[kk]); 
    kk++; 
  } 
 
} 

activity  :

package com.jisai.materialdesigndemo.tuixiangzhi; 
 
import android.content.DialogInterface; 
import android.graphics.Color; 
import android.os.Bundle; 
import android.support.design.widget.Snackbar; 
import android.support.v7.app.AlertDialog; 
import android.support.v7.app.AppCompatActivity; 
import android.support.v7.widget.Toolbar; 
import android.view.Menu; 
import android.view.MenuItem; 
import android.view.View; 
import android.widget.Button; 
 
import com.jisai.materialdesigndemo.R; 
 
import java.util.ArrayList; 
 
public class MainActivity_tuixiangzhi extends AppCompatActivity 
    { 
  ArrayList arrayList=new ArrayList<>(); 
      Button up,down,left,right,back,nextup,nextdown; 
      View_tuixiangzhi myImageView_circle; 
      Toolbar mToolbar; 
      int   LV=1; 
  @Override 
  protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_tuixiangzhi); 
    LV_data lv_data=new LV_data(); 
    arrayList=lv_data.arrayList; 
    mToolbar = (Toolbar) findViewById(R.id.toolbar); 
    // mToolbar.setBackgroundColor(0xFF42B1CD); 
    mToolbar.setTitle("推箱子(第"+LV+"关)");    //设置标题 
    mToolbar.setTitleTextColor(Color.parseColor("#ffffff"));  //设置标题颜色 
    setSupportActionBar(mToolbar); 
    getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
        // onBackPressed(); 
        finish(); 
        //Toast.makeText(getApplicationContext(),"返回",Toast.LENGTH_SHORT).show(); 
 
      } 
    }); 
 
 
 
 
 
 
    myImageView_circle= (View_tuixiangzhi) findViewById(R.id.nnn); 
 
    myImageView_circle.setPassLitener(new View_tuixiangzhi.PassLitener() { 
      @Override 
      public void pass() { 
 
        final AlertDialog.Builder normalDialog = 
            new AlertDialog.Builder(MainActivity_tuixiangzhi.this); 
        normalDialog.setTitle("恭喜你"); 
        normalDialog.setMessage("真厉害,你已通过本关!"); 
        normalDialog.setPositiveButton("下一关", 
            new DialogInterface.OnClickListener() { 
              @Override 
              public void onClick(DialogInterface dialog, int which) { 
                if(LV1){ 
                LV=LV-1; 
                myImageView_circle.setaaa(arrayList.get(LV-1)); 
                mToolbar.setTitle("推箱子(第"+LV+"关)");    //设置标题 
              } 
              break; 
            case R.id.xiayi: 
              if(LV

布局文件:

<&#63;xml version="1.0" encoding="utf-8"&#63;> 
 
 
     
 
   
     
 
 
     
      

关卡数据(二位数组),我加了40关,太长这里就贴一点。

package com.jisai.materialdesigndemo.tuixiangzhi; 
 
import java.util.ArrayList; 
 
/** 
 * Created by Administrator on 17-4-11. 
 */ 
public class LV_data { 
 final  ArrayListarrayList = new ArrayList<>(); 
 
  LV_data(){ 
    int[][] LV_1 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,5,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,1,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,3,1,3,5,0,0,0,0,0}, 
        {0,0,0,0,5,3,2,1,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,3,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,5,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_1); 
 
 
    int[][] LV_2 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,2,1,1,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,1,3,3,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,1,3,1,0,0,0,5,0,0,0,0}, 
        {0,0,0,0,0,0,1,0,0,0,5,0,0,0,0}, 
        {0,0,0,0,0,0,1,1,1,1,5,0,0,0,0}, 
        {0,0,0,0,0,1,1,1,0,1,1,0,0,0,0}, 
        {0,0,0,0,0,1,1,1,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_2); 
 
    int[][] LV_3 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,1,1,1,1,1,0,0,0,0,0}, 
        {0,0,0,0,0,3,0,0,0,1,1,1,0,0,0}, 
        {0,0,0,0,1,2,1,3,1,1,3,1,0,0,0}, 
        {0,0,0,0,1,5,5,0,1,3,1,0,0,0,0}, 
        {0,0,0,0,0,5,5,0,1,1,1,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_3); 
 
    int[][] LV_4 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,1,1,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,2,3,1,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,3,1,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,1,3,1,0,0,0,0,0,0}, 
        {0,0,0,0,0,5,3,1,1,0,0,0,0,0,0}, 
        {0,0,0,0,0,5,5,4,5,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_4); 
 
    int[][] LV_5 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,2,1,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,1,3,1,1,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,1,0,1,0,0,0,0,0,0}, 
        {0,0,0,0,5,0,1,0,1,1,0,0,0,0,0}, 
        {0,0,0,0,5,3,1,1,0,1,0,0,0,0,0}, 
        {0,0,0,0,5,1,1,1,3,1,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_5); 
 
    int[][] LV_6 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,1,1,1,1,1,0,0,0,0,0}, 
        {0,0,1,1,1,5,0,0,0,1,0,0,0,0,0}, 
        {0,0,1,0,1,0,1,1,1,1,0,0,0,0,0}, 
        {0,0,1,0,1,3,1,3,0,5,1,0,0,0,0}, 
        {0,0,1,0,1,1,4,1,1,0,1,0,0,0,0}, 
        {0,0,1,5,0,3,1,3,1,0,1,0,0,0,0}, 
        {0,0,0,1,1,1,1,0,1,0,1,0,0,0,0}, 
        {0,0,0,1,0,0,0,5,1,1,1,1,2,0,0}, 
        {0,0,0,1,1,1,1,1,0,0,1,1,1,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_6); 
 
    int[][] LV_7 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,1,1,1,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,1,3,1,5,5,1,3,1,0,0,0,0}, 
        {0,0,0,0,3,1,5,5,3,3,2,0,0,0,0}, 
        {0,0,0,0,1,1,5,5,1,3,1,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_7); 
 
    int[][] LV_8 ={//0是墙,1是空,2是人,3是空箱子,4是满箱子,5是花,6是人加花 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,1,1,1,1,0,0,0,0}, 
        {0,0,0,0,0,5,1,3,0,0,1,0,0,0,0}, 
        {0,0,0,0,5,5,3,1,3,1,1,2,0,0,0}, 
        {0,0,0,0,5,5,1,3,1,3,1,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,1,1,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, 
        {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} 
    }; 
    arrayList.add(LV_8); 

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。


推荐阅读
  • Eclipse 中 Maven 的基础配置指南
    本文详细介绍了如何在 Eclipse 环境中配置 Maven,包括环境变量的设置、Maven 插件的安装与配置等关键步骤,旨在帮助开发者顺利搭建开发环境。 ... [详细]
  • 本文介绍了ADB(Android Debug Bridge)的基本概念、安装方法、环境配置、连接真机步骤以及常用命令和高级技巧。ADB是一个强大的工具,适用于Android设备的开发和调试。 ... [详细]
  • 目录介绍01.CoordinatorLayout滑动抖动问题描述02.滑动抖动问题分析03.自定义AppBarLayout.Behavior说明04.CoordinatorLayo ... [详细]
  • 本文介绍了两种有效的方法来检查Android应用是否拥有特定权限,如媒体读写权限(media_rw)。通过这些方法,开发者和安全人员可以更好地了解应用的行为,确保其不会滥用权限。 ... [详细]
  • 本文详细介绍了ejabberd中的验证码服务、接收器以及服务器间通信的监督者和工作进程,包括它们的启动方式和主要功能。 ... [详细]
  • 深入理解JVM内存加载机制与实践
    本文通过一个简单的Java类`Person`的示例,详细解析了JVM在加载和运行时如何处理类和对象的内存分配过程。通过具体代码演示,帮助读者更好地理解和掌握JVM内存管理的核心概念。 ... [详细]
  • 本文深入探讨了在Java编程语言中,如何使用`org.apache.polygene.api.association.AssociationDescriptor.qualifiedName()`方法,并提供了多个实际应用的代码示例。这些示例源自GitHub、StackOverflow和Maven等知名平台,旨在帮助开发者更好地理解和应用这一方法。 ... [详细]
  • 本实验利用xmlspy2013和firefox工具,探讨如何编写和验证基于DTD的XML文档。实验包括分析XML实例以创建相应的DTD文档,并通过编写有效的XML文档来验证DTD的有效性。 ... [详细]
  • 本文详细介绍了MyBatis中的延迟加载功能,包括其基本概念、实现方式以及如何在实际开发中应用。通过具体的代码示例,帮助读者更好地理解和掌握这一优化数据库查询性能的重要技术。 ... [详细]
  • 在日常开发中,经常需要通过Web服务进行数据交互。然而,在参数传递时会遇到一些限制,例如自定义实体类和Hashtable等复杂数据类型无法直接传递。本文将详细介绍如何在ASP.NET环境中有效地传递Hashtable数据。 ... [详细]
  • 本文详细介绍了DOM(文档对象模型)的基本概念、结构及操作方法。DOM作为一种API,允许开发者以编程方式访问HTML和XML文档的结构,实现页面内容的动态修改。 ... [详细]
  • 本文详细探讨了在 Spring Boot 应用中遇到 'Invalid bound statement (not found)' 错误时的解决方法,重点检查 MyBatis 的配置文件中 mapper-locations 路径设置是否正确。 ... [详细]
  • 构建Struts 2 Web应用程序指南
    本文提供了一个详细的步骤指南,帮助开发者从零开始创建一个简单的Struts 2 Web应用程序,涵盖了从环境搭建到项目部署的全过程。 ... [详细]
  • 优化 DropDownList 与 TextBox 的交互体验
    本文介绍了一种解决方案,通过在 DropDownList 前添加一个 TextBox 来提升用户体验。当选项过多时,用户可以通过在 TextBox 中输入关键词来快速定位并选择相应的选项。 ... [详细]
  • 本教程将指导您完成 Spring Boot 应用程序中 MySQL 数据库的配置,并通过 JdbcTemplate 进行基本的数据操作测试。在此之前,我们已经成功打包并测试了 jar 和 war 包,同时实现了 JSP 页面的访问,但页面数据是静态配置的。现在,让我们一起进入数据库配置的世界。 ... [详细]
author-avatar
yoyokk99的秋天
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有