亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tiledlayer.java

?? 手機射擊游戲源代碼,nokia s60模擬器開發(fā)包,eclipse工具開發(fā).不可用于商業(yè)用途.
?? JAVA
字號:
package src;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class TiledLayer extends Layer
{
	int screenW,screenH,tileWidth,tileHeight;//**************************************
	public TiledLayer(int columns, int rows, Image image, int tileWidth,int tileHeight) 
	{
		super(columns >= 1 && tileWidth >= 1 ? columns * tileWidth : -1,
				rows >= 1 && tileHeight >= 1 ? rows * tileHeight : -1);
		updated = true;
		x_src = null;
		y_src = null;
		x_dest = null;
		y_dest = null;
		screenW=screenH=0;//***********************************
		this.tileWidth=tileWidth;//***********************************
		this.tileHeight=tileHeight;//*************************
		if (image.getWidth() % tileWidth != 0|| image.getHeight() % tileHeight != 0) 
		{
			throw new IllegalArgumentException();
		} 
		else 
		{
			this.columns = columns;
			this.rows = rows;
			cellMatrix = new int[rows][columns];
			int noOfFrames = (image.getWidth() / tileWidth)* (image.getHeight() / tileHeight);
			createStaticSet(image, noOfFrames + 1, tileWidth, tileHeight, true);
			return;
		}
	}
	public void setScreen(int w,int h)//************************************
	{
		screenW=w;screenH=h;
	}
	
//	public int createAnimatedTile(int staticTileIndex) 
//	{
//		if (staticTileIndex < 0 || staticTileIndex >= numberOfTiles)
//			throw new IndexOutOfBoundsException();
//		if (anim_to_static == null) 
//		{
//			anim_to_static = new int[4];
//			numOfAnimTiles = 1;
//		} 
//		else if (numOfAnimTiles == anim_to_static.length)
//		{
//			int new_anim_tbl[] = new int[anim_to_static.length * 2];
//			System.arraycopy(anim_to_static, 0, new_anim_tbl, 0,
//					anim_to_static.length);
//			anim_to_static = new_anim_tbl;
//		}
//		anim_to_static[numOfAnimTiles] = staticTileIndex;
//		numOfAnimTiles++;
//		
//		return -(numOfAnimTiles - 1);
//	}

//	public void setAnimatedTile(int animatedTileIndex, int staticTileIndex) 
//	{
//		if (staticTileIndex < 0 || staticTileIndex >= numberOfTiles)
//			throw new IndexOutOfBoundsException();
//		animatedTileIndex = -animatedTileIndex;
//		if (anim_to_static == null || animatedTileIndex <= 0
//				|| animatedTileIndex >= numOfAnimTiles) 
//		{
//			throw new IndexOutOfBoundsException();
//		}
//		else 
//		{
//			anim_to_static[animatedTileIndex] = staticTileIndex;
//			return;
//		}
//	}

	public int getAnimatedTile(int animatedTileIndex) 
	{
		animatedTileIndex = -animatedTileIndex;
		if (anim_to_static == null || animatedTileIndex <= 0
				|| animatedTileIndex >= numOfAnimTiles)
			throw new IndexOutOfBoundsException();
		else
			return anim_to_static[animatedTileIndex];
	}

	public void setCell(int col, int row, int tileIndex)
	{
		if (col < 0 || col >= columns || row < 0 || row >= rows)
			throw new IndexOutOfBoundsException();
		if (tileIndex > 0) 
		{
			if (tileIndex >= numberOfTiles)
				throw new IndexOutOfBoundsException();
		} 
		else if (tileIndex < 0&& (anim_to_static == null || -tileIndex >= numOfAnimTiles))
			throw new IndexOutOfBoundsException();
		cellMatrix[row][col] = tileIndex;
		updated = true;
	}

	public int getCell(int col, int row) 
	{
		if (col < 0 || col >= columns || row < 0 || row >= rows)
			throw new IndexOutOfBoundsException();
		else
			return cellMatrix[row][col];
	}

//	public void fillCells(int col, int row, int numCols, int numRows,int tileIndex) 
//	{
//		if (numCols < 0 || numRows < 0)
//			throw new IllegalArgumentException();
//		if (col < 0 || col >= columns || row < 0 || row >= rows
//				|| col + numCols > columns || row + numRows > rows)
//			throw new IndexOutOfBoundsException();
//		if (tileIndex > 0) 
//		{
//			if (tileIndex >= numberOfTiles)
//				throw new IndexOutOfBoundsException();
//		}
//		else if (tileIndex < 0&& (anim_to_static == null || -tileIndex >= numOfAnimTiles))
//			throw new IndexOutOfBoundsException();
//		for (int rowCount = row; rowCount < row + numRows; rowCount++)
//		{
//			for (int columnCount = col; columnCount < col + numCols; columnCount++)
//				cellMatrix[rowCount][columnCount] = tileIndex;
//		}
//		updated = true;
//	}

	public final int getCellWidth() 
	{
		return cellWidth;
	}

	public final int getCellHeight()
	{
		return cellHeight;
	}

	public final int getColumns() 
	{
		return columns;
	}

	public final int getRows() 
	{
		return rows;
	}

//	public void setStaticTileSet(Image image, int tileWidth, int tileHeight) 
//	{
//		updated = true;
//		if (tileWidth < 1 || tileHeight < 1
//			|| image.getWidth() % tileWidth != 0
//			|| image.getHeight() % tileHeight != 0)
//			throw new IllegalArgumentException();
//		setWidthImpl(columns * tileWidth);
//		setHeightImpl(rows * tileHeight);
//		int noOfFrames = (image.getWidth() / tileWidth)
//				* (image.getHeight() / tileHeight);
//		if (noOfFrames >= numberOfTiles - 1)
//			createStaticSet(image, noOfFrames + 1, tileWidth, tileHeight, true);
//		else
//			createStaticSet(image, noOfFrames + 1, tileWidth, tileHeight, false);
//	}

	public final void paint(Graphics g)
	{
		this.paint(g, false);
	}
	
	public final void paintLookDown(Graphics g)
	{
		this.paint(g, true);
	}
	private final void paint(Graphics g, boolean lookDown) 
	{
		if (g == null)
			throw new NullPointerException();
		if (visible)
		{
			int tileIndex = 0;
			if (updated) 
			{
				int arrayLength = 0;
				for (int row = 0; row < cellMatrix.length; row++) 
				{
					int totalCols = cellMatrix[row].length;
					for (int column = 0; column < totalCols; column++) 
					{
						tileIndex = cellMatrix[row][column];
						if (tileIndex != 0)
							arrayLength++;
					}
				}
				if (x_src == null || arrayLength > x_src.length) 
				{
					x_src = new int[arrayLength];
					y_src = new int[arrayLength];
					x_dest = new int[arrayLength];
					y_dest = new int[arrayLength];
				}
				tileArrayLength = arrayLength;	
				updated = false;//*********************************
			}//**************************************************			
				//**************************
			int ty = lookDown?y - this.cellHeight/2:y;
			int arrayIndex = 0;
			for (int row = 0; row < cellMatrix.length;) 
			{
				int tx = lookDown?x-this.cellWidth/2:x;
				int totalCols = cellMatrix[row].length;
				for (int column = 0; column < totalCols;) 
				{
					tileIndex = cellMatrix[row][column];
					if (tileIndex != 0) 
					{
						if (tileIndex < 0)
							tileIndex = getAnimatedTile(tileIndex);
						x_src[arrayIndex] = tileSetX[tileIndex];
						y_src[arrayIndex] = tileSetY[tileIndex];
						x_dest[arrayIndex] = tx;
						y_dest[arrayIndex] = ty;
						arrayIndex++;
					}
					column++;
					tx += lookDown?cellWidth/2:cellWidth;
				}

				row++;
				ty += lookDown?cellHeight/2:cellHeight;
			}			
			
//            drawTiledRegion(g, sourceImage, tileArrayLength, x_src, y_src, cellWidth, cellHeight, 0, x_dest, y_dest, 20);
			
			for(int i=0; i<tileArrayLength; i++)
			{
				if(x_dest[i]>0-tileWidth&&x_dest[i]<screenW&&y_dest[i]>0-tileHeight&&y_dest[i]<screenH)
				{
					g.setClip(this.x_dest[i], this.y_dest[i], this.cellWidth, this.cellHeight);
					g.drawImage(this.sourceImage, this.x_dest[i] - x_src[i], this.y_dest[i] - y_src[i], Graphics.LEFT | Graphics.TOP);
				}
			}
			
		}
	}
//		private void drawTiledRegion(Graphics g, Image image, int tileArrayLength, int x_src[], int y_src[], int cellWidth, int cellHeight, int l, int x_dest[], int y_dest[], int i1){
//		
//	}

	private void createStaticSet(Image image, int noOfFrames, int tileWidth,int tileHeight, boolean maintainIndices) 
	{
		cellWidth = tileWidth;
		cellHeight = tileHeight;
		int imageW = image.getWidth();
		int imageH = image.getHeight();
		sourceImage = image;
		numberOfTiles = noOfFrames;
		tileSetX = new int[numberOfTiles];
		tileSetY = new int[numberOfTiles];
		if (!maintainIndices) 
		{
			for (rows = 0; rows < cellMatrix.length; rows++) 
			{
				int totalCols = cellMatrix[rows].length;
				for (columns = 0; columns < totalCols; columns++)
					cellMatrix[rows][columns] = 0;
			}
			anim_to_static = null;
		}
		int currentTile = 1;
		for (int y = 0; y < imageH; y += tileHeight) 
		{
			for (int x = 0; x < imageW; x += tileWidth) 
			{
				tileSetX[currentTile] = x;
				tileSetY[currentTile] = y;
				currentTile++;
			}
		}
	}

	/**
	 * <code>cellHeight</code> 單元格的高度
	 */
	private int cellHeight;
	/**
	 * <code>cellWidth</code> 單元格的寬度
	 */
	private int cellWidth;
	/**
	 * <code>rows</code> 行數(shù)
	 */
	private int rows;
	/**
	 * <code>columns</code> 列數(shù)
	 */
	private int columns;
	/**
	 * <code>cellMatrix</code> 保存地圖貼圖數(shù)據(jù)索引值,第一維保存列數(shù)據(jù),第二維保存行數(shù)據(jù),每個數(shù)組元素保存一個貼圖的索引值
	 */
	private int cellMatrix[][];
	/**
	 * <code>sourceImage</code> 貼圖源圖片
	 */
	protected Image sourceImage;
	/**
	 * <code>numberOfTiles</code> 地圖貼圖索引的總數(shù)
	 */
	private int numberOfTiles;
	/**
	 * <code>tileSetX</code> 記錄每個貼圖在源圖中的起始X坐標
	 */
	int tileSetX[];
	/**
	 * <code>tileSetY</code> 記錄每個貼圖在源圖中的起始Y坐標
	 */
	int tileSetY[];
	private int anim_to_static[];
	private int numOfAnimTiles;
	private boolean updated;
	/**
	 * <code>tileArrayLength</code> 需繪制的單元格總數(shù)
	 */
	private int tileArrayLength;
	/**
	 * <code>x_src</code> 地圖單元格需繪制的圖片在源圖中的X坐標
	 */
	private int x_src[];
	/**
	 * <code>y_src</code> 地圖單元格需繪制的圖片在源圖中的X坐標
	 */
	private int y_src[];
	/**
	 * <code>x_dest</code> 每個地圖單元格的X坐標
	 */
	private int x_dest[];
	/**
	 * <code>y_dest</code> 每個地圖單元格的Y坐標
	 */
	private int y_dest[];
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美一区二区精品婷婷 | 91欧美激情一区二区三区成人| 成人h动漫精品一区二| 欧美性猛交一区二区三区精品| 精品国内二区三区| 一区二区三区资源| 国产自产视频一区二区三区| 91麻豆6部合集magnet| 欧美久久久久久久久中文字幕| 欧美一区二区在线不卡| 中文字幕中文在线不卡住| 日韩高清不卡在线| 91天堂素人约啪| 精品av综合导航| 亚洲午夜久久久| 大白屁股一区二区视频| 91精品国产品国语在线不卡| 久久在线免费观看| 亚洲精品菠萝久久久久久久| 国产伦精一区二区三区| 在线播放一区二区三区| 国产精品伦理一区二区| 久久机这里只有精品| 欧美在线一二三四区| 日本一二三四高清不卡| 麻豆成人91精品二区三区| 一本久道中文字幕精品亚洲嫩| 欧美一区二区精美| 一区二区三区美女视频| 国产成人午夜99999| 日韩一级片在线观看| 一区二区三区精品视频| 成人91在线观看| 国产视频视频一区| 美日韩黄色大片| 日本道免费精品一区二区三区| 国产日韩欧美制服另类| 久久国产精品无码网站| 91麻豆精品国产91久久久久| 一区二区三区精品久久久| 91亚洲男人天堂| 国产精品久久久久久户外露出| 日日骚欧美日韩| 91女厕偷拍女厕偷拍高清| 国产精品人妖ts系列视频| 国产精品一区二区久激情瑜伽 | 亚洲国产综合色| 国产高清久久久久| 精品福利一二区| 久久精品99国产国产精| 欧美一区二区在线免费观看| 性久久久久久久久| 欧美视频中文字幕| 夜夜嗨av一区二区三区| 成人91在线观看| 国产日韩精品一区| 国产成人免费视频精品含羞草妖精| 26uuu精品一区二区| 久久精品二区亚洲w码| 日韩一卡二卡三卡国产欧美| 青青草97国产精品免费观看无弹窗版| av在线播放成人| 亚洲三级免费观看| 色视频欧美一区二区三区| 亚洲色图19p| 91久久精品日日躁夜夜躁欧美| 成人欧美一区二区三区在线播放| av电影天堂一区二区在线| 精品福利一二区| 国产成人精品午夜视频免费| 国产丝袜美腿一区二区三区| 国产jizzjizz一区二区| 国产精品第五页| 色综合久久精品| 亚洲午夜电影网| 欧美日韩精品二区第二页| 亚洲老妇xxxxxx| 欧美日韩第一区日日骚| 欧美aⅴ一区二区三区视频| 精品第一国产综合精品aⅴ| 国产老妇另类xxxxx| 国产精品久久国产精麻豆99网站| 99热99精品| 亚洲综合色丁香婷婷六月图片| 91色视频在线| 五月激情综合色| 日韩欧美国产一区二区三区 | 2019国产精品| 国产mv日韩mv欧美| 亚洲免费av观看| 555www色欧美视频| 国产一区中文字幕| 国产日本欧洲亚洲| av电影在线不卡| 偷拍自拍另类欧美| 久久人人97超碰com| av网站免费线看精品| 一区二区三区在线视频免费观看| 欧美日韩精品一区视频| 国内精品写真在线观看| 国产精品久久久久aaaa樱花 | 亚洲欧美日韩久久| 欧美三级电影在线观看| 日韩av一区二区三区| 久久久精品国产99久久精品芒果 | 亚洲天堂久久久久久久| 欧美精品色一区二区三区| 国产最新精品免费| 亚洲黄色小视频| 精品对白一区国产伦| 色一区在线观看| 麻豆91免费观看| 亚洲天堂精品在线观看| 欧美v日韩v国产v| 99re热这里只有精品视频| 日本最新不卡在线| 中文字幕精品一区二区精品绿巨人 | 亚洲第一成人在线| 国产拍欧美日韩视频二区| 欧美性高清videossexo| 岛国精品一区二区| 精品一区二区三区香蕉蜜桃| 一区二区三区中文字幕电影| 欧美激情在线一区二区三区| 91麻豆精品国产91久久久资源速度 | 久久国产精品99久久久久久老狼 | 国产精品麻豆一区二区| 精品免费国产二区三区| 欧美三片在线视频观看| voyeur盗摄精品| 国产一区二区三区免费在线观看| 午夜精品成人在线视频| 亚洲激情在线播放| 国产日产欧美一区二区三区| 日韩视频免费观看高清在线视频| 在线观看一区不卡| 91理论电影在线观看| 成人永久aaa| 国产suv一区二区三区88区| 国内成人自拍视频| 久久精品国产秦先生| 青青草成人在线观看| 日韩一区精品字幕| 亚洲成av人片| 午夜久久电影网| 亚洲一区二区偷拍精品| 亚洲精品视频一区| 亚洲人成影院在线观看| 国产精品视频在线看| 国产欧美日韩中文久久| 久久这里只精品最新地址| 精品久久久久久久久久久院品网| 日韩一二三四区| 91精品视频网| 欧美一区二区三区小说| 欧美一区二区在线不卡| 91精品在线观看入口| 91精品国产91久久综合桃花| 91精品免费观看| 欧美一区二区三区四区久久| 欧美一级一级性生活免费录像| 91精品国模一区二区三区| 5858s免费视频成人| 91精品国产入口| 欧美一级欧美一级在线播放| 日韩一区二区电影在线| 26uuu亚洲婷婷狠狠天堂| 久久久久久久久一| 欧美激情一区二区三区不卡 | 精品国产欧美一区二区| 欧美精品一区二区久久婷婷| 久久一区二区三区四区| 中文字幕成人网| 亚洲免费高清视频在线| 午夜视频一区在线观看| 免费成人在线观看视频| 国产一区三区三区| 成人h动漫精品| 91国偷自产一区二区三区成为亚洲经典 | 欧美优质美女网站| 欧美老女人在线| 日韩欧美精品在线视频| 国产亚洲自拍一区| 中文字幕一区二区三区蜜月| 一片黄亚洲嫩模| 强制捆绑调教一区二区| 国产精品99久久不卡二区| 99久久精品99国产精品| 欧美日韩二区三区| 久久久久国产精品免费免费搜索| 国产精品丝袜91| 亚洲国产精品久久久久婷婷884 | 一区二区三区四区不卡在线| 日韩激情一二三区| 国产精品亚洲一区二区三区妖精 | 粉嫩欧美一区二区三区高清影视| 91香蕉视频在线| 欧美一级片免费看| 国产精品免费视频网站| 亚洲高清不卡在线观看|