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

📄 mapmanager.java

📁 Java吃豆子游戏
💻 JAVA
字号:
package org.loon.test;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
/**
 * 
 * <p>Title: LoonFramework</p>
 * <p>Description:</p>
 * <p>Copyright: Copyright (c) 2008</p>
 * <p>Company: LoonFramework</p>
 * <p>License: http://www.apache.org/licenses/LICENSE-2.0</p>
 * @author chenpeng  
 * @email:ceponline@yahoo.com.cn 
 * @version 0.1
 */
public class MapManager {
  int[] map0 = {
		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,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,
		0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,
		0,2,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,2,0,
		0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,
		0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
		0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,
		0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,
		0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,
		0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,
		0,1,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,
		0,2,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,2,0,
		0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,
		0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,
		0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,1,1,1,1,1,0,
		0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,
		0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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
	}; 
  int[] map;
  int remain;
  Image offImage = null;
  Graphics offG;

  public MapManager() {
	map = new int[map0.length];
  }
  public void init(Image offImage) {
	this.offImage = offImage;
  	offG = offImage.getGraphics();
	for(int i=0; i<map.length; i++)
	  map[i] = map0[i];

    int k;
	for(int j=0; j<27; j++) {
		for(int i=0; i<21; i++) {
			k=j*21+i;
			switch(map[k]) {
			  case 1:
			  	offG.setColor(Color.yellow);
			  	offG.fillRect(i*8+8+3, j*8+8+3, 2,2);
			  	break;
			  case 2:
			  	offG.setColor(Color.yellow);
			  	offG.fillArc(i*8+8+1, j*8+8+1, 6,6, 0,360);
			  	break;
			  default:
			  	break;
			}
		}
	}
    remain = 192;
  }
  public int getRemain() {
  	  return remain;
  }

  public int eatmap(int jx, int jy) {
	int eat = 0;

	if( ((jx%8)==0) && ((jy%8)==0) ) {
		int jxc = jx>>3;
		int jyc = jy>>3;
		eat = map[jyc*21+jxc];
		if(eat > 0) {
			map[jyc*21+jxc] = 0;
			remain--; 
			offG.setColor(Color.black);
			offG.fillRect(jxc*8+9, jyc*8+9, 6,6);
		}
	}
	return eat;
  }
  public int eatmap2(int jxc, int jyc) {
  	return eatmap(jxc<<3, jyc<<3);
  }



}

⌨️ 快捷键说明

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