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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? tiledlayer.java

?? 該源碼實(shí)現(xiàn)了j2me中用midp1.0實(shí)現(xiàn)的midp2.0的game類
?? JAVA
字號(hào):
/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *  Copyright(c) 2004 Jordi Martin Perez
*/

package org.piratis.j2me.core.game;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import org.piratis.j2me.core.BBox2D;
import org.piratis.j2me.core.QuickList;

/**
 * A type of Layer composed of a grid of 
 * cells which can contain a reduced set of predefined images. 
 * This class allows large virtual layers to be created 
 * without the need for an extremely large Image. It is
 * commonly used to creat very large scrolling backgrounds.
 * 
 * @author		Jordi Mart韓
 * @copyright	Copyright (c) 2004
 * @created 	30-jun-2004
 * @version		$Id: TiledLayer.java,v 1.5 2004/07/29 20:13:06 piratis Exp $
 */

public class TiledLayer 
	extends Layer 
{
    /**
     * Tile's columns
     */
    private int columns;
    /**
     * Tile's rows
     */
    private int rows;
    /**
     * Height of one tile
     */
    private int tileHeight;
    /**
     * Width of one tile
     */
    private int tileWidth;
    /**
     * Grid
     */
    private int[][] grid;
    /**
     * Where common tiles will be stored
     */
    private QuickList commonTiles;
    /**
     * The image containing the tiles
     */
    private Image tiles;
    private int nTilesRow;
    
    /**
     * Creates a new TiledLayer.<br>
     * <br>
     * TODO:
     * @param columns
     * @param rows
     * @param image
     * @param tileWidth
     * @param tileHeight
     */
    public TiledLayer (int columns, int rows, Image image,
            int tileWidth, int tileHeight)
    {
        this.columns = columns;
        this.rows = rows;
        this.grid = new int	[columns][rows];
        this.tiles = image;
        this.nTilesRow = image.getWidth() / tileWidth;

        // void initialization
        this.fillCells(0, 0, columns, rows, 0);
        
        // layer values
        this.tileWidth = tileWidth;
        this.tileHeight = tileHeight;
        this.bbox.width = columns * tileWidth;
        this.bbox.height = rows * tileHeight;
        
        // animated tiles
        this.commonTiles = new QuickList();
    }
    
	/**
	 * Sets the given tileIndex in a given region.
     * @param col top-left region column
     * @param row top-left region row
     * @param colNumber region col number
     * @param rowNumber region row number
     * @param tileIndex tile index to set
     */
    public void fillCells(int col, int row, 
            int colNumber, int rowNumber, int tileIndex)
    {
        int i, j;
        for (i = col + colNumber - 1; i >= col; i--)
            for (j = row + rowNumber - 1; j >= row; j--)
                this.grid[i][j] = tileIndex;
    }
   
    /**
     * Sets the contents of a cell.
     * @param col column from the grid
     * @param row row from the grid
     * @param tileIndex the index of the tile
     */
    public void setCell(int col, int row, int tileIndex)
    {
        this.grid[col][row] = tileIndex;
    }

    /**
     * Gets cell's contents
     * @param col column from the grid
     * @param row row from the grid
     * @return the index of the tile in the cell
     */
    public int getCell(int col, int row)
    {
        return this.grid[col][row];
    }

    /**
     * Cretates a new common tile returning the index referring to this new
     * common tile. It is initially assigned with the provided tileIndex.
     * @param tileIndex
     * @return
     */
    public int createCommonTile(int tileIndex)
    {
		this.commonTiles.add(new Integer(tileIndex));
		return -this.commonTiles.length();
    }
    

    /**
     * Gets the tile referenced by the given common tile. 
     * @param commonTileIndex the index of the common tile.
     * @return the tile index currently associated with the common tile.
     */
    public int getCommonTile(int commonTileIndex)
    {
        return ((Integer) this.commonTiles.elementAt((-commonTileIndex)-1)).intValue();
    }
    
    /**
     * Changes the tile associated to this common tile.
     * @param commonTileIndex
     * @param tileIndex
     */
    public void setCommonTile(int commonTileIndex, int tileIndex)
    {
        this.commonTiles.setElementAt(new Integer(tileIndex),
                (-commonTileIndex)-1);
    }

    /**
	 * @see org.piratis.j2me.core.game.Layer#paint(javax.microedition.lcdui.Graphics)
	 */
	public void paint(Graphics g) 
	{
	    // get clipping
	    int clipX, clipY, clipW, clipH;
	    clipX = g.getClipX(); clipY = g.getClipY();
	    clipW = g.getClipWidth(); clipH = g.getClipWidth();
	    // check inside clipping
	    if (!this.bbox.collide(clipX, clipY, clipW, clipH)) return;
	    // where to begin
	    int startCol = (clipX - this.bbox.x) / this.tileWidth;
	    int startRow = (clipY - this.bbox.y) / this.tileHeight;
	    // where to end
	    int endCol = Math.min(startCol + (clipW / this.tileWidth) + 1, 
	            this.columns - 1);
	    int endRow = Math.min(startRow + (clipH / this.tileHeight) + 1,
	            this.rows - 1);
	    // go, go, go!
	    int i, j, transX, transY, oldTransX, oldTransY, tileNum, auxTrans;
	    // store previous translation values
	    oldTransX = g.getTranslateX();
	    oldTransY = g.getTranslateY();
	    // start moving translation through the drawn tiles
        g.translate(this.bbox.x + (endCol * this.tileWidth), 
        	this.bbox.y + (endRow * this.tileHeight));
	    for (i = endCol; i >= startCol; i--)
	    {
	        for (j = endRow; j >= startRow; j--)
	        {
	    	    tileNum = this.grid[i][j];
	    	    // check if 'common' (i.e. animated) tile
	    	    if (tileNum < 0)
	    	        tileNum = this.getCommonTile(tileNum);
	    	    if (tileNum > 0)
	    	    {
		            // store clipping
		    	    clipX = g.getClipX(); clipY = g.getClipY();
		    	    clipW = g.getClipWidth(); clipH = g.getClipWidth();
		    	    // set new clipping -> drawing at '0,0' because of translation!
		    	    g.clipRect(0, 0, this.tileWidth, this.tileHeight);
		    	    // calc image to draw
		    	    tileNum--; // easier to calc image location 
		    	    transX = (tileNum % this.nTilesRow) * this.tileWidth;  // tileNum % nTilesRow = col
		    	    transY = (tileNum / this.nTilesRow) * this.tileHeight; // tileNum / nTilesRow = row
		    	    // draw there
		    	    g.drawImage(this.tiles, -transX, -transY, Layer.TOP_LEFT);
		    	    // restore clipping
		    	    g.setClip(clipX, clipY, clipW, clipH);
	    	    }
	    	    // move clipping
	    	    g.translate(0, -this.tileHeight);
	        }
	        // move clipping
	        g.translate(-this.tileWidth, this.tileHeight*(endRow-startRow+1));
	    }
	    // restore clipping
	    g.translate(oldTransX - g.getTranslateX(), 
	            oldTransY - g.getTranslateY());
	}
	
	/**
	 * Check colliding but checking cells.
	 * @param l Layer to check
	 * @return whether colliding exists
	 */
	public boolean cellCollides(Layer l)
	{
	    // where to begin
	    BBox2D layerBox = l.bbox;
	    int startCol = Math.max(0, (layerBox.x - this.bbox.x) / this.tileWidth);
	    int startRow = Math.max(0, (layerBox.y - this.bbox.y) / this.tileHeight);
	    // where to end
	    int endCol = Math.min(startCol + (layerBox.width / this.tileWidth) + 1, 
	            this.columns - 1);
	    int endRow = Math.min(startRow + (layerBox.height / this.tileHeight) + 1,
	            this.rows - 1);
	    // go, go, go!!
	    int i, j, boxX, boxY;
	    // limits will be calculated incrementaly (boxX and boxY) -> more efficient
	    boxX = this.bbox.x + endCol*this.tileWidth;
	    for (i = endCol; i >= startCol; i--)
	    {
	        boxY = this.bbox.y + endRow*this.tileHeight;
	        for (j = endRow; j >= startRow; j--)
	        {
	            if (this.grid[i][j] != 0)
	            {
	                if (layerBox.collide(boxX, boxY, tileWidth, tileHeight))
	                {
	                    return true;
	                }
	            }
	            boxY -= tileHeight;
	        }
	        boxX -= tileWidth;  
	    }
	    return false;
	}
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人性生交大片免费看视频在线| 日韩伦理免费电影| 欧美高清在线视频| 亚洲精品国产精华液| 日韩经典一区二区| 国产一区二区三区美女| 成人黄色av网站在线| 欧美三级电影网站| 久久色在线视频| 一区二区三区毛片| 国产一区二区三区观看| 91麻豆精品秘密| 精品国产免费一区二区三区香蕉| 国产精品美女久久福利网站| 天堂va蜜桃一区二区三区| 国产精品一区久久久久| 欧美在线小视频| 国产婷婷色一区二区三区在线| 亚洲综合免费观看高清完整版| 国产真实精品久久二三区| 91激情五月电影| 久久久国产精华| 日韩电影在线免费观看| 91在线精品一区二区三区| 日韩欧美一二区| 一区二区三区成人| 国产一区二区成人久久免费影院 | 欧美精品第1页| 国产日韩av一区| 婷婷激情综合网| 91小视频免费观看| 久久综合成人精品亚洲另类欧美| 一区二区三区精密机械公司| 精久久久久久久久久久| 欧美日韩一区二区不卡| 国产精品乱码妇女bbbb| 精品一区二区三区蜜桃| 欧美三级韩国三级日本一级| 中文字幕一区av| 国产一区欧美日韩| 91精品国产综合久久香蕉麻豆| 亚洲欧洲日产国码二区| 国产一区二区在线视频| 欧美狂野另类xxxxoooo| 一区二区三区在线免费视频| 高清成人免费视频| 久久综合九色综合97_久久久| 午夜婷婷国产麻豆精品| 色老汉av一区二区三区| 成人欧美一区二区三区1314| 国产精一区二区三区| 日韩精品一区二区三区中文不卡 | 91高清在线观看| 国产精品乱码一区二区三区软件| 国产剧情在线观看一区二区| 日韩欧美一卡二卡| 日本不卡视频在线| 欧美日韩国产片| 亚洲一区二区三区在线播放| 91国模大尺度私拍在线视频| 亚洲美女屁股眼交| 97久久超碰国产精品| 中文字幕国产精品一区二区| 大美女一区二区三区| 国产视频在线观看一区二区三区 | 国产精品网站在线观看| 国内成+人亚洲+欧美+综合在线| 欧美浪妇xxxx高跟鞋交| 日韩av中文字幕一区二区 | 欧美人与禽zozo性伦| 亚洲免费观看高清| 91麻豆精品一区二区三区| 亚洲婷婷在线视频| 91麻豆精品在线观看| 亚洲精品美国一| 欧美在线free| 夜夜爽夜夜爽精品视频| 色av一区二区| 亚洲午夜av在线| 欧美一区二区三区免费大片| 日本欧美一区二区三区乱码| 日韩女优视频免费观看| 精品一区二区三区免费| 国产亚洲精品福利| 成人美女视频在线观看18| 中文字幕在线观看不卡视频| 91视频在线观看免费| 樱花草国产18久久久久| 精品视频1区2区| 日本aⅴ精品一区二区三区| 日韩欧美电影在线| 国产精品88av| 亚洲精品高清在线观看| 欧美日韩国产小视频| 久久激情五月婷婷| 日本一区二区三区免费乱视频| 99天天综合性| 午夜欧美视频在线观看 | 国产成人在线视频网址| 国产精品福利电影一区二区三区四区| av一本久道久久综合久久鬼色| 亚洲欧美国产77777| 欧美视频在线观看一区二区| 欧美aaa在线| 欧美国产日韩精品免费观看| 91视视频在线直接观看在线看网页在线看| 亚洲狠狠爱一区二区三区| 欧美大尺度电影在线| 国产91丝袜在线观看| 亚洲一卡二卡三卡四卡无卡久久 | 欧美aaa在线| 中文字幕电影一区| 欧美视频自拍偷拍| 激情综合五月天| 亚洲欧美日韩成人高清在线一区| 欧美精品v国产精品v日韩精品| 国内精品伊人久久久久av一坑| 中文av字幕一区| 欧美精品99久久久**| 国产精品亚洲午夜一区二区三区| 一区二区三区中文字幕电影 | 久久国产婷婷国产香蕉| 国产免费观看久久| 69堂亚洲精品首页| 成人短视频下载| 日韩精品每日更新| 中文字幕一区二区在线观看| 欧美日本高清视频在线观看| 成人深夜视频在线观看| 午夜亚洲福利老司机| 国产精品久久毛片av大全日韩| 91精品国产福利在线观看| av在线播放一区二区三区| 日韩av在线发布| 亚洲精品乱码久久久久| 久久久久久**毛片大全| 欧美区一区二区三区| 成人午夜av在线| 久久草av在线| 亚洲妇女屁股眼交7| 综合精品久久久| 久久综合九色综合97婷婷女人 | 日韩福利电影在线观看| 亚洲天堂a在线| 久久免费国产精品| 欧美精品在线观看一区二区| 99久久精品免费精品国产| 精品综合免费视频观看| 亚洲国产一区二区三区 | 99精品1区2区| 国产一区视频导航| 日韩av不卡一区二区| 亚洲午夜国产一区99re久久| 国产精品福利在线播放| 久久久久久电影| 精品国产一区二区三区av性色| 欧美视频精品在线| 91在线视频18| 不卡一区在线观看| 国产精品一区专区| 毛片av一区二区三区| 午夜久久久久久久久| 一区二区三区欧美日韩| 中文字幕佐山爱一区二区免费| 久久精品人人做| 日韩欧美成人一区二区| 欧美日韩精品一区二区| 欧美影片第一页| 91福利国产精品| 91久久奴性调教| 99久久精品情趣| 99视频精品在线| 91亚洲精品久久久蜜桃| 99精品久久只有精品| 床上的激情91.| 成人免费黄色大片| 成人午夜激情在线| 成人动漫中文字幕| 成人午夜视频在线| 成人午夜视频在线观看| 成人国产精品免费网站| 国产a区久久久| 成人黄色小视频| 91免费看`日韩一区二区| 99久久精品免费精品国产| 99久久久免费精品国产一区二区| 北岛玲一区二区三区四区| 成人app软件下载大全免费| 不卡一区中文字幕| 色婷婷综合激情| 91精彩视频在线观看| 欧美无乱码久久久免费午夜一区 | 日韩av电影天堂| 免费成人在线观看视频| 久久精品国产99国产| 国产一区二区三区免费观看| 成人一区在线观看| 97久久超碰国产精品电影| 色乱码一区二区三区88| 欧美日韩精品福利|