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

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

?? board.java

?? 本文件是關(guān)于手機(jī)上的推箱子的源代碼; 沒(méi)辦法下載不了。只能傳了。
?? JAVA
字號(hào):
/* * @(#)Board.java	1.4 04/08/31 * * Copyright (c) 1999-2004 Sun Microsystems, Inc. All rights reserved.  * PROPRIETARY/CONFIDENTIAL * Use is subject to license terms */package example.pushpuzzle;import javax.microedition.lcdui.*;/** * The class Board knows how the pieces move, handles undo, and * handles reading of screens. */public class Board {    private int level;    private byte[] array;    private byte[] pathmap;	// used for runTo to find shortest path    private int width, height;    private int pusher;	// position of the pusher at index into array    private int packets = 0;	// total number of packets    private int stored = 0;	// number of packets in Stores    private byte[] moves;	// recorded moves    private int nmoves;	// number of moves executed    private int npushes;	// number of pushes executed    // Move directions    public static final int LEFT = 0;    public static final int RIGHT = 3;    public static final int UP = 1;    public static final int DOWN = 2;    public static final int MOVEPACKET = 4;    // Bit definitions for pieces of each board position    public static final byte GROUND = 0;	// If nothing there    public static final byte STORE = 1;	// If it is a storage place    public static final byte PACKET = 2;	// If it has a packet    public static final byte WALL = 4;	// If it is a wall    public static final byte PUSHER = 8;	// If the pusher is there    /**     * Creates new Board initialized to a simple puzzle.     */    public Board() {        moves = new byte[200];        screen0();    }    /**     * Create the hard coded simple game board.     */    public void screen0() {        width = 9;        height = 7;        array = new byte[width * height];        level = 0;        nmoves = 0;        npushes = 0;        for (int x = 0; x < width; x++) {            for (int y = 0; y < height; y++) {                byte t = (x == 0 || y == 0 ||                x == width - 1 || y == height - 1) ?                WALL : GROUND;                set(x, y, t);            }        }        packets = 2;        stored = 0;        set(2, 2, PACKET);        set(4, 4, PACKET);        set(4, 2, STORE);        set(6, 4, STORE);        pusher = index(1, 1);    }    /**     * Move the pusher in the direction indicated.     * If there is a wall, don't move.     * if there is a packet in that direction, try to move it.     * @param move the direction; one of LEFT, RIGHT, UP, DOWN     * @return the direction actually moved, -1 if not moved     */    public int move(int move) {        int obj = pusher + indexOffset(move);        // Handle the simple cases        if ((array[obj] & WALL) != 0)            return -1;        int m = movePacket(obj, move);        if (m < 0)            return -1;	// If can't move packet, done!        pusher = obj;	// move the pusher to the new spot        saveMove(m);	return m;    }    /**     * Move the packet in the direction indicated relative to     * the pusher.  If it fits into a store position remember.     * @return -1 if can't be moved or the updated move     * including the packet flag if there was a packet to move.     */    private int movePacket(int index, int move) {        if ((array[index] & PACKET) == 0)            return move;	// no packet to move        int dest = index + indexOffset(move);        if (array[dest] > STORE)            return -1;	// can't move packet into next spot.        // Remove packet from current location        array[index] &= ~PACKET;        if ((array[index] & STORE) != 0)            stored--;        // Insert packet into new location        array[dest] |= PACKET;        if ((array[dest] & STORE) != 0)            stored++;        npushes++;	// count pushes done        return move + MOVEPACKET;    }    /*     * Save a move, extending the array if necessary.     */    private void saveMove(int move) {        if (nmoves >= moves.length) {            byte[] n = new byte[moves.length + 50];            System.arraycopy(moves, 0, n, 0, moves.length);            moves = n;        }        moves[nmoves++] = (byte)move;    }    /**     * Undo the most recent move     * @return the move undone;  if none -1 is returned;     *  See LEFT, RIGHT, UP, DOWN, and MOVEPACKET     */    public int undoMove() {        if (nmoves <= 0)            return -1;        int move = moves[--nmoves];        int rev = (move & 3) ^ 3;	// reverse the direction        int back = pusher + indexOffset(rev);        if ((move & MOVEPACKET) != 0) {            npushes--;	// "unpush"            movePacket(pusher + indexOffset(move), rev);	// move packet        }        pusher = back;	return move;    }    /**     * Determine if the screen has been solved.     */    public boolean solved() {        return packets == stored;    }    /**     * Move the player to the position (x,y), if possible. Return      * the direction it moved if successful, otherwise -1.     * The position (x,y) must be empty.     * @param x window coordinate     * @param y window coordinate     * @return the direction that it moved, -1 is not moved;     *  See LEFT, RIGHT, UP, DOWN, MOVEPACKET     */    public int runTo(int x, int y, int max) {        int target = index(x, y);        if (target < 0 || target >= array.length)            return -1;        if (target == pusher)            return -1;	// already there	/* Fill the path map */        if (pathmap == null || pathmap.length != array.length) {            pathmap = new byte[array.length];        }        // Fill with unset value.        for (int i = 0; i < pathmap.length; i++)            pathmap[i] = 127;        // flood fill search to find a shortest path to the push point.        findTarget(target, (byte)0);	/*	 * if we didn't make it back to the players position,	 * there is no valid path to that place.	 */        if (pathmap[pusher] == 127) {            return -1;        } else {            // We made it back, so let's walk the path we just built up	    // Save the final move to return            int pathlen = pathmap[pusher];            int pathmin = pathlen - max;	    int dir = -1;            for (pathlen--; pathlen >= pathmin; pathlen--) {                if (pathmap[pusher - 1] == pathlen) {		    dir = LEFT;                    saveMove(dir);                    pusher--;                } else if (pathmap[pusher + 1] == pathlen) {		    dir = RIGHT;                    saveMove(dir);                    pusher++;                } else if (pathmap[pusher - width] == pathlen) {		    dir = UP;                    saveMove(dir);                    pusher -= width;                } else if (pathmap[pusher + width] == pathlen) {		    dir = DOWN;                    saveMove(dir);                    pusher += width;                } else {		    /*		     * if we get here, something is SERIOUSLY wrong,		     * so we should abort		     */                    throw new RuntimeException("runTo abort");                }            }	    return dir;        }    }    /**     * Find the shortest path to the pusher via a fill search algorithm     */    private void findTarget(int t, byte pathlen) {        if (array[t] > STORE)            return;	// Either a wall or looped back to player	// Already tried here and this way is longer        if (pathmap[t] <= pathlen)                return;        pathmap[t] = pathlen++;	// set path length to this location        if (t == pusher)            return;		// avoiding ArrayIndexOutOfBoundException	if (t - 1 >= 0)	    findTarget(t - 1, pathlen);	// to previous cell	if ((t + 1) < array.length)	    findTarget(t + 1, pathlen);	// to next cell	if (t - width >= 0)	    findTarget(t - width, pathlen);	// to previous row	if ((t + width) < array.length)		    findTarget(t + width, pathlen);	// to next row    }    /**     * Return the pieces at the location.     * @param x location in the board.     * @param y location in the board.     * @return flags indicating what pieces are in this board location.     * Bit flags; combinations of WALL, PUSHER, STORE, PACKET.     */    public byte get(int x, int y) {        int offset = index(x, y);        if (offset == pusher)            return (byte)(array[offset] | PUSHER);        else            return array[offset];    }    /**     * Set the value of the location.     */    private void set(int x, int y, byte value) {        array[index(x, y)] = value;    }    /**     * Compute the index in the array of the x, y location.     */    private int index(int x, int y) {        if (x < 0 || x >= width ||        y < 0 || y >= height)            return -1;        return y * width + x;    }    /**     * Get the location of the pusher.     * It is returned as an int with the lower 16 bits being     * the x index and the upper 16 bits being the y index.     * @return the encoded location of the pusher.     */    public int getPusherLocation() {	int x = pusher % width;	int y = pusher / width;	return (y << 16) + x;    }    /**     * Compute the offset in the array of the cell relative     * to the current pusher location in the direction of the move.     * Note: the walls around the edge always make a +/- guard band.     * Also, the order of evaluation should never try to get to +/- 2.     */    private int indexOffset(int move) {        switch (move & 3) {            case LEFT:                return -1;            case RIGHT:                return +1;            case UP:                return -width;            case DOWN:                return +width;        }        return 0;    }    /**     * Read a board from a stream.     * Read it into a fixed size array and then shrink to fit.     */    public void read(java.io.InputStream is, int l) {        final int W = 20;        final int H = 20;        byte[] b = new byte[W * H];        // Add resize code later.        int c, w = 0;        int x = 0, y = 0, xn = 0, yn = 0, npackets = 0;        try {            while ((c = is.read()) != -1) {                switch (c) {                    case '\n':                        if (x > w) {                            w = x;                        }                        y++;                        x = 0;                        break;                    case '$':                        b[y * W + x++] = PACKET;                        npackets++;                        break;                    case '#':                        b[y * W + x++] = WALL;                        break;                    case ' ':                        b[y * W + x++] = GROUND;                        break;                    case '.':                        b[y * W + x++] = STORE;                        break;                    case '*':                        b[y * W + x] = PACKET;                        b[y * W + x++] |= STORE;                        npackets++;			stored++;                        break;                    case '+':	// player and store in same place                        b[y * W + x++] = STORE;                    case '@':                        xn = x;                        yn = y;                        x++;                        break;                }            }        } catch (java.io.IOException ex) {            ex.printStackTrace();        }        if (y > 0) {            array = new byte[w * y];            if (y > w) {	// Switch x for y while copying                width = y;                height = w;                for (y = 0; y < width; y++) {                    for (x = 0; x < w; x++) {                        array[index(y, x)] = b[y * W + x];                    }                }                pusher = index(yn, xn);            } else {                width = w;                height = y;                array = new byte[width * height];                for (y = 0; y < height; y++) {                    for (x = 0; x < width; x++) {                        array[index(x, y)] = b[y * W + x];                    }                }                pusher = index(xn, yn);            }            stored = 0;            packets = npackets;            level = l;            nmoves = 0;            npushes = 0;        }    }    /**     * Get the width of the game board.     */    public int getWidth() {        return width;    }    /**     * Get the height of the board.     */    public int getHeight() {        return height;    }    /**     * Get the number of moves to get this far.     */    public int getMoves() {        return nmoves;    }    /**     * Get the number of packets pushed around.     */    public int getPushes() {        return npushes;    }    /**     * Get the number of packets stored.     */    public int getStored() {        return stored;    }    /**     * Convert a left/right direction into an offset.     */    private int dx(int dir) {        if (dir == LEFT)            return -1;        if (dir == RIGHT)            return +1;        return 0;    }    /**     * Convert a up/down direction into an offset.     */    private int dy(int dir) {        if (dir == UP)            return -1;        if (dir == DOWN)            return +1;        return 0;    }}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美丝袜自拍制服另类| 成人黄色电影在线| 日韩三级在线观看| 福利一区二区在线| 一区二区三区**美女毛片| 国产欧美精品在线观看| 亚洲午夜久久久| 国产69精品久久久久777| 欧美一二三四区在线| 亚洲午夜一区二区| 国产麻豆精品95视频| 91香蕉视频mp4| 精品三级在线观看| 国内精品伊人久久久久av一坑| 国产精品久久久久aaaa| 在线成人免费观看| 国产做a爰片久久毛片| 亚洲精品视频免费看| 欧美老肥妇做.爰bbww| 91福利在线导航| 国产专区欧美精品| 午夜精品一区二区三区免费视频| 国产亚洲一本大道中文在线| 日韩欧美久久一区| 日韩精品资源二区在线| 色哟哟一区二区在线观看| 日本欧美一区二区三区乱码| 日韩中文字幕麻豆| 亚洲成人激情自拍| 亚洲成人动漫在线观看| 国产精品一区二区久久精品爱涩| 日韩国产欧美三级| 国产综合色在线视频区| 国产一区二区福利视频| 成人免费毛片嘿嘿连载视频| 成人在线综合网| 91蜜桃免费观看视频| 久久久影院官网| 美脚の诱脚舐め脚责91 | 国产欧美一区二区三区网站| 中文字幕欧美三区| 蜜桃视频一区二区三区| 色婷婷久久综合| 欧美日韩一二三区| 欧美成人三级在线| 久久9热精品视频| 精品无码三级在线观看视频| 99久久99久久精品免费观看| 亚洲色大成网站www久久九九| 国产成人在线观看免费网站| 久久天天做天天爱综合色| 国产精品电影院| 亚洲国产日韩综合久久精品| 欧美96一区二区免费视频| 不卡的av电影| 日韩丝袜美女视频| 欧美激情综合五月色丁香小说| 亚洲久草在线视频| 狠狠色狠狠色综合系列| 97se亚洲国产综合自在线| 欧美白人最猛性xxxxx69交| 中文字幕不卡一区| 亚洲成人一区在线| 国产一区 二区| 日韩三级精品电影久久久| 亚洲精品成人少妇| 国产电影一区二区三区| 欧美一级淫片007| 亚洲午夜电影网| 亚洲gay无套男同| 91蜜桃网址入口| 亚洲综合丁香婷婷六月香| 欧美日韩中文精品| 久久综合久久综合久久综合| 亚洲一区在线免费观看| 91免费国产视频网站| 国产精品嫩草影院av蜜臀| 国内精品写真在线观看| 久久综合九色综合97婷婷 | 1区2区3区精品视频| 国产美女视频91| 久久久精品国产免大香伊| 激情综合色综合久久| 日韩欧美美女一区二区三区| 奇米一区二区三区| 欧美精品一区二区三区蜜桃视频| 热久久一区二区| 午夜电影一区二区三区| 欧美日韩五月天| 天天影视色香欲综合网老头| 欧美在线999| 天堂在线亚洲视频| www精品美女久久久tv| 国产精品主播直播| 中文字幕第一区二区| 一本久道中文字幕精品亚洲嫩| 伊人婷婷欧美激情| 欧美高清激情brazzers| 蜜桃av噜噜一区| 亚洲国产精华液网站w| 色综合天天综合给合国产| 午夜久久久久久| 337p粉嫩大胆色噜噜噜噜亚洲| 成人激情av网| 婷婷亚洲久悠悠色悠在线播放| 日韩欧美成人午夜| 91尤物视频在线观看| 午夜精品国产更新| 国产欧美精品国产国产专区| 色网综合在线观看| 久久不见久久见免费视频7| 国产精品初高中害羞小美女文| 欧美色图12p| 国产福利精品导航| 日本精品免费观看高清观看| 免费在线视频一区| 一区二区三区.www| 亚洲国产激情av| 91精品免费在线观看| 91玉足脚交白嫩脚丫在线播放| 麻豆视频一区二区| 亚洲一区二区在线免费观看视频| 久久久欧美精品sm网站| 欧美日本国产视频| 色综合中文字幕国产| 免费久久99精品国产| 一区二区三区视频在线看| 欧美国产日产图区| 日韩精品一区二区三区三区免费| 色噜噜狠狠色综合中国| 国产一区二区三区在线观看免费| 亚洲第一福利视频在线| 亚洲欧美怡红院| 国产欧美日韩在线看| 精品国产乱码久久久久久闺蜜 | 粉嫩高潮美女一区二区三区| 欧美精品在线观看一区二区| 91在线观看视频| hitomi一区二区三区精品| 国产精品一区二区在线观看网站| 奇米一区二区三区| 日本伊人色综合网| 日韩精品乱码免费| 午夜日韩在线电影| 亚洲高清视频的网址| 亚洲第一会所有码转帖| 亚洲国产裸拍裸体视频在线观看乱了| 国产精品进线69影院| 中文字幕中文字幕一区二区| 国产精品理论在线观看| 国产精品国产自产拍在线| 中文字幕欧美国产| 国产精品久久久久永久免费观看 | 日韩电影在线观看电影| 日本最新不卡在线| 国产真实乱偷精品视频免| 国产乱码精品一区二区三区五月婷 | 亚洲国产一区二区在线播放| 洋洋av久久久久久久一区| 亚洲国产日韩精品| 日韩在线一区二区| 精品一区二区三区香蕉蜜桃| 国产黄色精品网站| 91日韩在线专区| 欧美日韩国产另类不卡| 26uuu另类欧美| 亚洲欧美另类在线| 午夜精品一区在线观看| 国内精品自线一区二区三区视频| 成人不卡免费av| 欧美日韩成人综合在线一区二区 | 日本精品视频一区二区| 91精品国产综合久久小美女| 欧美成人女星排名| 亚洲免费av在线| 美女一区二区三区| 99re这里都是精品| 日韩一区二区在线观看视频播放| 国产精品欧美经典| 婷婷开心激情综合| 成人av电影在线播放| 欧美一区二区三区在线观看| 国产精品欧美久久久久一区二区| 日韩一区精品视频| 白白色 亚洲乱淫| 午夜久久电影网| 国产aⅴ综合色| 在线91免费看| 综合分类小说区另类春色亚洲小说欧美| 丝袜亚洲另类欧美| 色综合色狠狠天天综合色| 精品国产a毛片| 日韩—二三区免费观看av| 91麻豆福利精品推荐| 国产欧美日本一区视频| 久久精品久久99精品久久| 91久久精品网| 中文字幕日韩av资源站| 国产精品一区一区三区| 日韩免费成人网|