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

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

?? tiledlayer.java

?? 在手機環(huán)境里運行的J2ME坦克類射擊游戲源代碼
?? JAVA
字號:
/*
 *  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;
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一卡二卡| 婷婷六月综合亚洲| 99精品久久免费看蜜臀剧情介绍 | 国产精品一区二区不卡| 久久人人97超碰com| 狠狠色丁香婷婷综合| 久久精品视频在线免费观看| 国产91丝袜在线播放| 亚洲欧洲日产国产综合网| 一本一道综合狠狠老| 亚洲国产日韩av| 日韩欧美一级特黄在线播放| 国产老女人精品毛片久久| 亚洲国产成人午夜在线一区| 日本精品一区二区三区高清| 日韩高清在线一区| 久久婷婷久久一区二区三区| 成人精品免费网站| 午夜婷婷国产麻豆精品| 精品国产91乱码一区二区三区 | 蜜臀av一区二区在线观看| 久久久久久久久一| 色婷婷久久久综合中文字幕| 日日夜夜一区二区| 欧美激情在线一区二区三区| 91高清在线观看| 国模一区二区三区白浆| 亚洲精品水蜜桃| 精品欧美久久久| 在线观看免费成人| 国内精品视频一区二区三区八戒| 亚洲精品视频在线看| 精品国产免费人成在线观看| 91麻豆国产香蕉久久精品| 奇米精品一区二区三区在线观看一| 国产欧美日韩在线| 在线播放91灌醉迷j高跟美女| 国产成人在线免费| 午夜精品福利一区二区蜜股av| 国产亚洲成年网址在线观看| 在线观看www91| 国产成人日日夜夜| 蜜臀av一区二区| 亚洲伊人色欲综合网| 久久久噜噜噜久久中文字幕色伊伊| 在线观看成人小视频| 成人爱爱电影网址| 久久99国产精品免费| 亚洲超丰满肉感bbw| 国产精品传媒视频| 亚洲精品一区二区三区福利| 欧美性极品少妇| 99久久精品一区| 国模大尺度一区二区三区| 三级欧美韩日大片在线看| 亚洲美女视频一区| 中文字幕精品一区二区三区精品| 欧美一区二区精品| 欧美剧情电影在线观看完整版免费励志电影| 成人午夜激情片| 国产精品1024| 国产麻豆精品视频| 久久国产人妖系列| 欧美aⅴ一区二区三区视频| 亚洲一区二区美女| 亚洲啪啪综合av一区二区三区| 中文字幕中文字幕在线一区| 日本一区二区电影| 亚洲国产成人在线| 欧美激情自拍偷拍| 国产精品久久久久久久久搜平片| 久久精品免视看| 久久久久久久久久美女| 久久亚洲综合av| 久久久久国产免费免费| 久久夜色精品国产欧美乱极品| 精品粉嫩超白一线天av| 亚洲精品一区二区三区99| 久久久久亚洲综合| 中文无字幕一区二区三区| 欧美国产日本视频| 中文字幕综合网| 亚洲欧美激情插| 亚洲成av人片在www色猫咪| 天天影视网天天综合色在线播放| 午夜精品福利久久久| 蜜臀av在线播放一区二区三区| 久久成人麻豆午夜电影| 久久国产精品72免费观看| 国产一区二区三区蝌蚪| 国产成人综合自拍| 色猫猫国产区一区二在线视频| 91久久国产综合久久| 欧美三日本三级三级在线播放| 欧美日韩免费电影| 日韩一二三四区| 国产亚洲欧美激情| 亚洲同性同志一二三专区| 亚洲一级电影视频| 免费欧美在线视频| 国产在线国偷精品产拍免费yy| 福利电影一区二区| 91极品美女在线| 日韩欧美一区二区久久婷婷| 欧美激情一区二区三区不卡 | 欧美一区永久视频免费观看| 日韩精品自拍偷拍| 中文字幕av一区二区三区免费看| 中文字幕五月欧美| 亚欧色一区w666天堂| 国产麻豆精品95视频| 在线免费观看日本欧美| 欧美zozo另类异族| 亚洲黄网站在线观看| 极品尤物av久久免费看| 一本色道综合亚洲| 欧美大片拔萝卜| 亚洲色图欧美在线| 久久爱www久久做| 91香蕉视频黄| 日韩欧美中文字幕一区| 成人欧美一区二区三区| 美国毛片一区二区| 91麻豆视频网站| 精品裸体舞一区二区三区| 亚洲欧美日韩在线| 黄网站免费久久| 欧美日韩高清一区二区三区| 日本一区二区免费在线| 婷婷开心久久网| 91女人视频在线观看| 久久久久久久一区| 青青草国产精品亚洲专区无| 一本到三区不卡视频| 久久久高清一区二区三区| 五月激情六月综合| 色哟哟在线观看一区二区三区| 久久久久亚洲蜜桃| 日本中文一区二区三区| 欧美性生活大片视频| 中文字幕一区二区三区色视频| 国产在线不卡一卡二卡三卡四卡| 欧美日韩国产成人在线免费| 亚洲欧美经典视频| 99久久伊人精品| 久久精品一区四区| 久久精品国产网站| 91精品国产乱码| 亚洲成人av免费| 欧美日韩亚洲综合在线| 亚洲欧美日韩一区二区三区在线观看| 国产福利91精品| 久久综合网色—综合色88| 秋霞午夜鲁丝一区二区老狼| 欧美人妇做爰xxxⅹ性高电影| 亚洲三级在线观看| 波多野结衣视频一区| 日本一区二区综合亚洲| 高清不卡一区二区在线| 欧美经典三级视频一区二区三区| 国产乱人伦偷精品视频免下载| 欧美成人video| 免费成人你懂的| 日韩你懂的在线观看| 蜜臀99久久精品久久久久久软件| 91精品一区二区三区在线观看| 午夜亚洲国产au精品一区二区| 欧美欧美欧美欧美首页| 视频一区二区三区中文字幕| 这里只有精品免费| 免费观看91视频大全| 欧美本精品男人aⅴ天堂| 国产真实乱对白精彩久久| 久久夜色精品国产噜噜av| 国产iv一区二区三区| 国产精品美女久久久久久久| 成人激情小说乱人伦| 国产精品国产三级国产普通话三级| 99精品在线观看视频| 亚洲综合色自拍一区| 4438x亚洲最大成人网| 老司机精品视频在线| 久久久精品综合| av激情综合网| 亚洲一区二区三区小说| 777久久久精品| 激情成人综合网| 亚洲三级小视频| 欧美喷水一区二区| 国产一区激情在线| 中文字幕 久热精品 视频在线| 色哟哟一区二区| 久久精品免费观看| 国产欧美精品一区二区色综合朱莉| 成人开心网精品视频| 一区二区三区欧美在线观看| 欧美日韩成人在线一区| 国产一区三区三区| 亚洲另类在线一区| 精品国产麻豆免费人成网站|