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

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

?? board.java

?? 名稱:games
?? JAVA
字號(hào):
/* * * Copyright ? 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */package example.tilepuzzle;import example.About;import java.util.Random;import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;public class Board extends Canvas implements CommandListener {    // commands    static final int CMD_ABOUT = 0;    static final int CMD_EXIT = 1;    static final int CMD_OPTIONS = 2;    static final int CMD_RESET = 3;    static final int CMD_START = 4;    static final int CMD_UNLOCK = 5;    static final int CMD_ZLAST = 6; // must be ze last, of course    // state variables    static final int INITIALIZED = 0;    static final int PLAYING = 1;    static final int WON = 2;    MIDlet midlet;    Display dpy;    Options options;    // this string must be exactly 15 characters long    String letters = "RATEYOURMINDPAL";    Font font;    Piece blankp;    Piece[] all;    Piece[][] grid;    Random rand;    // grid origin in pixels    int gridx;    int gridy;    // grid width and height, in cells    int gridw;    int gridh;    // cell geometry in pixels    int cellw;    int cellh;    int cellyoff;    int cellxoff;    Command[] cmd;    int gameState;    boolean cheated;    public Board(MIDlet midlet_) {        int i;        // "global" variables        midlet = midlet_;        dpy = Display.getDisplay(midlet);        gridw = 4;        gridh = 4;        font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM);        // REMIND update when font metrics info gets implemented        cellw = font.charWidth('M') + 7;        cellh = font.getHeight() + 1;        cellxoff = 3;        cellyoff = 0;        gridx = (getWidth() - (gridw * cellw) + 1) / 2;        gridy = 10;        cheated = false;        rand = new Random();        // create the grid arrays        grid = new Piece[gridw][];        for (i = 0; i < gridw; i++) {            grid[i] = new Piece[gridh];        }        all = new Piece[gridw * gridh];        for (i = 0; i < ((gridw * gridh) - 1); i++) {            int x = i % gridw;            int y = i / gridw;            String s = letters.substring(i, i + 1);            grid[x][y] = all[i] = new Piece(s, i, x, y, i < ((gridw * gridh) / 2));        }        // make the special blank piece        blankp = new Piece(null, (gridw * gridh) - 1, gridw - 1, gridh - 1, false);        grid[gridw - 1][gridh - 1] = blankp;        all[(gridw * gridh) - 1] = blankp;        // set up commands        cmd = new Command[CMD_ZLAST];        cmd[CMD_ABOUT] = new BoardCommand("About", Command.HELP, 5, CMD_ABOUT);        cmd[CMD_EXIT] = new BoardCommand("Exit", Command.EXIT, 6, CMD_EXIT);        cmd[CMD_OPTIONS] = new BoardCommand("Options", Command.SCREEN, 3, CMD_OPTIONS);        cmd[CMD_RESET] = new BoardCommand("Reset", Command.SCREEN, 1, CMD_RESET);        cmd[CMD_START] = new BoardCommand("Start", Command.SCREEN, 1, CMD_START);        cmd[CMD_UNLOCK] = new BoardCommand("Unlock", Command.SCREEN, 4, CMD_UNLOCK);        // set up the listener        setCommandListener(this);        // set up options screen        options = new Options(dpy, this);        // set up initial state        setState(INITIALIZED);    }    void D(String s) {        System.out.println(s);    }    void setGrid(Piece p, int x, int y) {        grid[x][y] = p;        p.setLocation(x, y);    }    // swap the piece at sx, sy with the blank piece    // assumes that this is a legal move    void moveBlank(int swapx, int swapy) {        setGrid(grid[swapx][swapy], blankp.x, blankp.y);        setGrid(blankp, swapx, swapy);    }    // swaps the pieces at (x1, y1) and (x2, y2)    // no parity checking is done!        void swap(int x1, int y1, int x2, int y2) {        Piece t = grid[x1][y1];        setGrid(grid[x2][y2], x1, y1);        setGrid(t, x2, y2);    }    boolean isSolved() {        for (int i = 0; i < gridh; i++) {            for (int j = 0; j < gridw; j++) {                if (!grid[j][i].isHome()) {                    return false;                }            }        }        return true;    }    // return a random integer in the range [0..n)    int randRange(int n) {        int r = rand.nextInt() % n;        if (r < 0) {            r += n;        }        return r;    }    // randomize by making random moves    void randomize_by_moving() {        int dx;        int dy;        int v;        for (int i = 0; i < 100; i++) {            dx = dy = 0;            v = (rand.nextInt() & 2) - 1; // 1 or -1            if ((rand.nextInt() & 1) == 0) {                dx = v;            } else {                dy = v;            }            if ((blankp.x + dx) < 0) {                dx = 1;            }            if ((blankp.x + dx) == gridw) {                dx = -1;            }            if ((blankp.y + dy) < 0) {                dy = 1;            }            if ((blankp.y + dy) == gridh) {                dy = -1;            }            moveBlank(blankp.x + dx, blankp.y + dy);        }        // now move the blank tile to the lower right corner        while (blankp.x != (gridw - 1))            moveBlank(blankp.x + 1, blankp.y);        while (blankp.y != (gridh - 1))            moveBlank(blankp.x, blankp.y + 1);    }    // shuffle the tiles randomly and place the blank at the bottom right    void shuffle() {        int limit = (gridw * gridh) - 1;        Piece[] ta = new Piece[limit];        Piece temp;        System.arraycopy(all, 0, ta, 0, limit);        for (int i = 0; i < limit; i++) {            int j = randRange(limit);            temp = ta[j];            ta[j] = ta[i];            ta[i] = temp;        }        for (int i = 0; i < limit; i++) {            setGrid(ta[i], i / gridw, i % gridw);        }        setGrid(blankp, gridw - 1, gridh - 1);    }    void randomize(boolean hard) {        shuffle();        int ra;        int rb;        int x;        int y;        if (hard) {            ra = 7;            rb = 0;        } else {            ra = 0;            rb = 7;        }        x = rand.nextInt() & 1;        y = rand.nextInt() & 1;        if ((x == 1) && (y == 1)) {            x = 2;            y = 0;        }        swap(x, y, all[ra].x, all[ra].y);        swap((rand.nextInt() & 1) + 1, 3, all[rb].x, all[rb].y);        if ((displacement() & 1) == 1) {            swap(1, 3, 2, 3);        }    }    // Compute and return the displacement, that is, the number of    // pairs of tiles that are out of order.  The blank tile *must*    // be in the lower right corner.    int displacement() {        boolean[] temp = new boolean[(gridw * gridh) - 1]; // all false        int n = 0;        for (int i = 0; i < gridh; i++) {            for (int j = 0; j < gridw; j++) {                Piece p = grid[j][i];                if (p == blankp) {                    continue;                }                temp[p.serial] = true;                for (int k = 0; k < p.serial; k++) {                    if (!temp[k]) {                        n++;                    }                }            }        }        return n;    }    void resetGrid() {        Piece[] temp = new Piece[gridw * gridh];        int k = 0;        for (int i = 0; i < gridw; i++) {            for (int j = 0; j < gridh; j++) {                temp[k++] = grid[i][j];            }        }        for (k = 0; k < temp.length; k++) {            temp[k].goHome();        }    }    void rearrangeFunnily(boolean hard) {        resetGrid();        if (hard) {            // RATE YOUR MIDP LAN            swap(0, 0, 3, 1);            swap(2, 2, 3, 2);            swap(3, 2, 0, 3);            swap(0, 3, 2, 3);        } else {            // RATE YOUR MIDP NAL            swap(2, 2, 3, 2);            swap(3, 2, 0, 3);        }    }    void setState(int ns) {        gameState = ns;        switch (gameState) {        case INITIALIZED:            addCommand(cmd[CMD_ABOUT]);            removeCommand(cmd[CMD_RESET]);            addCommand(cmd[CMD_START]);            addCommand(cmd[CMD_UNLOCK]);            addCommand(cmd[CMD_EXIT]);            addCommand(cmd[CMD_OPTIONS]);            break;        case PLAYING:            addCommand(cmd[CMD_ABOUT]);            addCommand(cmd[CMD_RESET]);            removeCommand(cmd[CMD_START]);            removeCommand(cmd[CMD_UNLOCK]);            addCommand(cmd[CMD_EXIT]);            addCommand(cmd[CMD_OPTIONS]);            break;        case WON:            addCommand(cmd[CMD_ABOUT]);            removeCommand(cmd[CMD_RESET]);            addCommand(cmd[CMD_START]);            addCommand(cmd[CMD_UNLOCK]);            addCommand(cmd[CMD_EXIT]);            addCommand(cmd[CMD_OPTIONS]);            break;        }    }    public void commandAction(Command c, Displayable d) {        switch (((BoardCommand)c).tag) {        case CMD_ABOUT:            About.showAbout(Display.getDisplay(midlet));            break;        case CMD_EXIT:            midlet.notifyDestroyed();            break;        case CMD_OPTIONS:            dpy.setCurrent(options);            break;        case CMD_RESET:            cheated = false;            resetGrid();            setState(INITIALIZED);            repaint();            break;        case CMD_START:            cheated = false;            if (options.funny) {                rearrangeFunnily(options.hard);            } else {                randomize(options.hard);            }            setState(PLAYING);            repaint();            break;        case CMD_UNLOCK:            cheated = true;            setState(PLAYING);            repaint();            break;        }    }    public void showNotify() {        // System.out.println("Board: showNotify");    }    public void hideNotify() {        // System.out.println("Board: hideNotify");    }    public void paint(Graphics g) {        g.setColor(0xFFFFFF);        g.fillRect(0, 0, getWidth(), getHeight());        g.translate(gridx, gridy);        g.setColor(0);        g.drawRect(-2, -2, (gridw * cellw) + 2, (gridh * cellh) + 2);        for (int j = 0; j < gridw; j++) {            for (int k = 0; k < gridh; k++) {                grid[j][k].paint(g);            }        }        if (gameState == WON) {            g.translate(-g.getTranslateX(), -g.getTranslateY());            g.setColor(0);            g.setFont(Font.getDefaultFont());            g.drawString((cheated ? "CHEATER!" : "YOU WIN!"), getWidth() / 2, getHeight() - 1,                Graphics.BOTTOM | Graphics.HCENTER);        }    }    public void keyPressed(int code) {        if (gameState != PLAYING) {            return;        }        int game = getGameAction(code);        int swapx = blankp.x;        int swapy = blankp.y;        int direction = (options.reversed ? (-1) : 1);        switch (game) {        case Canvas.UP:            swapy += direction;            break;        case Canvas.DOWN:            swapy -= direction;            break;        case Canvas.LEFT:            swapx += direction;            break;        case Canvas.RIGHT:            swapx -= direction;            break;        default:            return;        }        if ((swapx < 0) || (swapx >= gridw) || (swapy < 0) || (swapy >= gridh)) {            return;        }        moveBlank(swapx, swapy);        repaint();        if (isSolved()) {            setState(WON);        }    }    class Piece {        String label;        boolean inv;        int serial; // serial number for ordering        int ix; // initial location in grid coordinates        int iy; // initial location in grid coordinates        int x; // current location in grid coordinates        int y; // current location in grid coordinates        Piece(String str, int ser, int nx, int ny, boolean v) {            label = str;            serial = ser;            x = ix = nx;            y = iy = ny;            inv = v;        }        void setLocation(int nx, int ny) {            x = nx;            y = ny;        }        boolean isHome() {            return (x == ix) && (y == iy);        }        void goHome() {            setGrid(this, ix, iy);        }        // assumes background is white        void paint(Graphics g) {            int px = x * cellw;            int py = y * cellh;            if (label != null) {                if (inv) {                    // black outlined, white square with black writing                    g.setColor(0);                    g.setFont(font);                    g.drawRect(px, py, cellw - 2, cellh - 2);                    g.drawString(label, px + cellxoff, py + cellyoff, Graphics.TOP | Graphics.LEFT);                } else {                    // black square with white writing                    g.setColor(0);                    g.fillRect(px, py, cellw - 1, cellh - 1);                    g.setColor(0xFFFFFF);                    g.setFont(font);                    g.drawString(label, px + cellxoff, py + cellyoff, Graphics.TOP | Graphics.LEFT);                }            }        }    }    class BoardCommand extends Command {        int tag;        BoardCommand(String label, int type, int pri, int tag_) {            super(label, type, pri);            tag = tag_;        }    }}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲精品视频在线看| 国产亚洲综合色| 狠狠色综合播放一区二区| 日韩视频免费观看高清完整版在线观看| 毛片不卡一区二区| 美女爽到高潮91| 久久久欧美精品sm网站| 国产精品影视天天线| 国产精品乱码人人做人人爱| 国产剧情在线观看一区二区| 精品国产乱码久久久久久闺蜜| 国产一区二区三区在线观看免费视频| 国产精品久久三区| 91麻豆精品国产自产在线观看一区| 美女视频黄频大全不卡视频在线播放| 欧美韩国日本不卡| 日韩一区二区三| 一本大道综合伊人精品热热 | 精品国产a毛片| 91国偷自产一区二区开放时间 | 一区二区三区鲁丝不卡| 欧美一区二区三区四区五区| 久久国产免费看| 爽好多水快深点欧美视频| 久久美女高清视频| 欧美一卡在线观看| 欧美吻胸吃奶大尺度电影| 国产麻豆午夜三级精品| 天堂蜜桃一区二区三区| 国产精品成人免费精品自在线观看| 欧美日韩国产精选| 色偷偷一区二区三区| 国产一区二区三区在线观看精品| 一区二区三区中文免费| 免费人成精品欧美精品| 亚洲天堂免费看| 国产精品情趣视频| 国产精品久久久久久福利一牛影视| 日韩欧美成人激情| 欧美一区二区成人| 日韩免费高清视频| 精品国产亚洲一区二区三区在线观看| 欧美日韩国产另类不卡| 欧美在线免费播放| 欧美日韩成人一区| 91精品国产高清一区二区三区蜜臀 | 一区二区三区在线观看国产| 精品国产一区二区三区四区四 | 国模少妇一区二区三区| 麻豆精品在线视频| 九九久久精品视频| 国产成人av网站| 色综合中文字幕国产| 国产精品一区二区在线看| 久久成人精品无人区| 看电视剧不卡顿的网站| 日韩精品亚洲专区| 国精品**一区二区三区在线蜜桃| 国内外成人在线| av在线一区二区三区| 色8久久人人97超碰香蕉987| 91蜜桃网址入口| 日韩一区二区三区视频| 精品国产制服丝袜高跟| 国产视频视频一区| 成人97人人超碰人人99| 成人综合婷婷国产精品久久免费| 99久久亚洲一区二区三区青草| 色悠悠久久综合| 精品国产伦一区二区三区观看方式 | 亚洲女厕所小便bbb| 午夜视频久久久久久| 欧美一区二区三区爱爱| 国产精品视频你懂的| 亚洲激情图片一区| 国产黑丝在线一区二区三区| 成人小视频免费在线观看| 欧美日韩一区二区三区高清| 欧美伦理视频网站| 亚洲欧美综合色| 粉嫩在线一区二区三区视频| 色综合av在线| 国产精品久久久久天堂| 日韩精品午夜视频| 在线观看亚洲成人| 国产精品久久福利| 麻豆高清免费国产一区| 91在线播放网址| 国产欧美一区二区三区在线老狼 | 亚洲午夜一区二区| 国产成人亚洲精品青草天美| av一区二区三区| 日韩三级伦理片妻子的秘密按摩| 中文一区在线播放| 国产一区二区中文字幕| 欧美挠脚心视频网站| 国产精品国产三级国产普通话三级| 亚洲男同性视频| 风流少妇一区二区| 国产丝袜美腿一区二区三区| 亚洲欧洲日韩在线| 国产经典欧美精品| 欧美国产一区二区| 高清不卡一二三区| 中文字幕精品综合| 91美女蜜桃在线| 亚洲一区二区三区四区五区中文| 国产成人在线色| 中文字幕精品—区二区四季| 日韩成人一区二区| 日韩一卡二卡三卡| 久久爱www久久做| 久久久久97国产精华液好用吗| 日韩中文字幕区一区有砖一区| 在线视频综合导航| 一区二区免费视频| 制服丝袜在线91| 久久99热国产| 国产欧美精品一区二区色综合 | 国产日本欧洲亚洲| 成人av网址在线观看| 亚洲欧美日本在线| 日韩亚洲欧美成人一区| 黑人巨大精品欧美一区| 国产欧美一区二区精品忘忧草| aaa国产一区| 日韩国产高清影视| 国产精品的网站| 欧美变态凌虐bdsm| 99re这里只有精品视频首页| 国产精品乱码人人做人人爱| 成人亚洲一区二区一| 亚洲人一二三区| 欧美mv日韩mv国产| 一本一本大道香蕉久在线精品| 午夜精品一区二区三区电影天堂| 欧美精品一区二区三区蜜桃| 国内久久婷婷综合| 亚洲6080在线| 综合激情成人伊人| 精品成人免费观看| 欧美精品自拍偷拍动漫精品| 日本伊人精品一区二区三区观看方式 | 欧美日韩国产一级| 91在线一区二区三区| 乱中年女人伦av一区二区| 欧美韩国日本一区| 欧美精品一区二区三区视频| jlzzjlzz亚洲日本少妇| 青青草国产成人av片免费| 亚洲女性喷水在线观看一区| 欧美一区二区美女| 欧美性受极品xxxx喷水| 成人禁用看黄a在线| 奇米777欧美一区二区| 亚洲男同1069视频| 亚洲美女屁股眼交3| 中文一区二区在线观看| 777午夜精品免费视频| 欧美在线综合视频| 欧美年轻男男videosbes| 色婷婷狠狠综合| 91福利视频网站| 中文字幕日韩欧美一区二区三区| 欧美精品一区二区三区在线| 欧美午夜精品理论片a级按摩| 成人国产精品免费观看动漫| 日韩福利电影在线| 香蕉久久夜色精品国产使用方法| 亚洲色图一区二区| 一区二区三区在线视频免费| 久久久久国产成人精品亚洲午夜| 51精品视频一区二区三区| 欧美日韩视频在线第一区| 欧美最猛性xxxxx直播| 欧美亚洲一区二区三区四区| 丁香六月综合激情| 91麻豆免费观看| 欧美蜜桃一区二区三区| 欧美精品在线观看一区二区| 在线观看一区不卡| 欧美v国产在线一区二区三区| 欧美不卡视频一区| 国产精品久久久久久久午夜片| 69精品人人人人| 欧美日本在线观看| 91麻豆成人久久精品二区三区| 黄色日韩网站视频| 色婷婷久久久久swag精品 | 在线视频你懂得一区二区三区| 制服丝袜亚洲网站| 亚洲福利一二三区| 色综合久久综合网97色综合| 日韩欧美卡一卡二| 亚洲高清久久久| 色综合久久久久综合99| 欧美va亚洲va国产综合| 亚洲欧洲性图库| 国产激情一区二区三区桃花岛亚洲| 一本色道亚洲精品aⅴ|