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

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

?? worm.java

?? 名稱:games
?? JAVA
字號:
/* * * Copyright ? 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. *//* * Worm.java * * Created on March 30, 2001, 16:15 * @version */package example.wormgame;import java.util.Vector;import javax.microedition.lcdui.Graphics;/** * A Worm is a combination of one or more WormLinks. The first * WormLink is the physical tail of the worm. The last WormLink * is the physical head of the worm. As the worm moves, it adds * one space to the head and then removes one from the tail. If the * worm eats a piece of food, the head adds one space but the tail * will not remove one. In this manner, the worm will grow outward * from its head. */public class Worm {    /* Possible directions for the worm */    public static final byte DOWN = 2;    public static final byte LEFT = 4;    public static final byte RIGHT = 6;    public static final byte UP = 8;    private static final int INIT_X = 3;    private static final int INIT_Y = 8;    private static final int INIT_LEN = 8;    private static final byte INIT_DIR = RIGHT;    // The direction of the worm's head    private byte currentDirection;    // The individual worm links that form the worm    private Vector worm = new Vector(5, 2);    private boolean needUpdate;    private boolean moveOnNextUpdate;    private boolean hasEaten;    public Worm(WormPit pit) {        regenerate();    }    /**     * Regenerate the worm in its initial position. This is used     * to restart the game after the worm is killed.     */    public void regenerate() {        synchronized (worm) {            worm.removeAllElements();            worm.addElement(new WormLink(INIT_X, INIT_Y, INIT_LEN, INIT_DIR));            // Reset class variables            currentDirection = INIT_DIR;            needUpdate = false;            hasEaten = false;            moveOnNextUpdate = false;        }    }    /**     * Change the direction of the worm. It will only change     * directions if you set a direction that is 90 degrees     * different from the current direction of the worm.     */    public void setDirection(byte direction) {        synchronized (worm) {            if ((direction != currentDirection) && !needUpdate) {                WormLink sl = (WormLink)worm.lastElement();                int x = sl.getEndX();                int y = sl.getEndY();                switch (direction) {                case UP:                    if (currentDirection != DOWN) {                        y--;                        needUpdate = true;                    }                    break;                case DOWN:                    if (currentDirection != UP) {                        y++;                        needUpdate = true;                    }                    break;                case LEFT:                    if (currentDirection != RIGHT) {                        x--;                        needUpdate = true;                    }                    break;                case RIGHT:                    if (currentDirection != LEFT) {                        x++;                        needUpdate = true;                    }                    break;                }                if (needUpdate == true) {                    worm.addElement(new WormLink(x, y, 0, direction));                    currentDirection = direction;                }            }        }    }    /**     * Schedule the worm for growth. The next time the update()     * method is invoked, the worm will move forward by one cell.     */    public void moveOnUpdate() {        synchronized (worm) {            moveOnNextUpdate = true;        }    }    /**     * Update the worm. If the worm is scheduled to grow, this     * method will grow the worm head by one cell and potentially     * shrink the tail by one cell. If the worm has eaten a piece     * of food, the tail will not shrink.     *     * If the worm is not scheduled to grow, this method will     * do nothing.     */    public void update(Graphics g) throws WormException {        WormLink head;        WormLink sl;        int headX;        int headY;        if (!moveOnNextUpdate) {            return;        }        synchronized (worm) {            head = (WormLink)worm.lastElement(); // the worm 'head'            head.increaseLength();            if (!hasEaten) {                WormLink tail;                tail = (WormLink)worm.firstElement(); // the worm 'tail'                int tailX = tail.getX();                int tailY = tail.getY();                tail.decreaseLength();                if (tail.getLength() == 0) {                    worm.removeElement(tail);                }                // Clear last block of the tail                g.setColor(WormPit.ERASE_COLOUR);                drawLink(g, tailX, tailY, tailX, tailY, 1);            } else {                hasEaten = false;            }            needUpdate = false;            // Make sure we're still in bounds            if (!WormPit.isInBounds(head.getEndX(), head.getEndY())) {                throw new WormException("over the edge"); // You're dead Jim            }            headX = (byte)head.getEndX();            headY = (byte)head.getEndY();            // Draw the head            g.setColor(WormPit.DRAW_COLOUR);            drawLink(g, headX, headY, headX, headY, 1);            // See if we ate ourself            for (int i = 0; i < (worm.size() - 1); i++) {                sl = (WormLink)worm.elementAt(i);                if (sl.contains(headX, headY)) {                    throw new WormException("you ate yourself");                }            }        }    }    /**     * Draw a worm link.     */    public void drawLink(Graphics g, int x1, int y1, int x2, int y2, int len) {        // Convert coordinates to the drawing area        len *= WormPit.CELL_SIZE;        if (x1 == x2) {            x1 *= WormPit.CELL_SIZE;            if (y2 < y1) {                y1 = y2 * WormPit.CELL_SIZE;            } else {                y1 *= WormPit.CELL_SIZE;            }            g.fillRect(x1, y1, WormPit.CELL_SIZE, len);        } else {            y1 *= WormPit.CELL_SIZE;            if (x2 < x1) {                x1 = x2 * WormPit.CELL_SIZE;            } else {                x1 *= WormPit.CELL_SIZE;            }            g.fillRect(x1, y1, len, WormPit.CELL_SIZE);        }    }    /**     * Draw the entire worm. Logically, the worm is composed of     * one or more links. A worm is usually composed of a few     * straight segments. This allows us to paint a full worm     * with a minimum of draw calls.     */    public void paint(Graphics g) {        WormLink sl;        int x1;        int x2;        int y1;        int y2;        int len;        for (int i = 0; i < worm.size(); i++) {            sl = (WormLink)worm.elementAt(i);            x1 = sl.getX();            x2 = sl.getEndX();            y1 = sl.getY();            y2 = sl.getEndY();            len = sl.getLength();            drawLink(g, x1, y1, x2, y2, len);        }    }    /**     * Signals the worm to eat a food item     */    public void eat() {        hasEaten = true;    }    /**     * Get the X coordinate of the cell that contains the worm's head.     */    public int getX() {        synchronized (worm) {            return ((WormLink)worm.lastElement()).getEndX();        }    }    /**     * Get the Y coordinate of the cell that contains the worm's head.     */    public int getY() {        synchronized (worm) {            return ((WormLink)worm.lastElement()).getEndY();        }    }    /**     * Returns true if the worm contains the given cell coordinate.     */    public boolean contains(int x, int y) {        WormLink sl;        synchronized (worm) {            for (int i = 0; i < worm.size(); i++) {                sl = (WormLink)worm.elementAt(i);                if (sl.contains(x, y)) {                    return true;                }            }        }        return false;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品视频1区2区3区| 老司机精品视频线观看86| 久久综合狠狠综合久久综合88 | 中文字幕一区二区三区在线观看| 91精品国产91综合久久蜜臀| 欧美男生操女生| 欧美日韩综合不卡| 欧美人与禽zozo性伦| 欧美日韩二区三区| 欧美一级理论性理论a| 日韩欧美国产精品| 久久精品男人天堂av| 欧美激情艳妇裸体舞| 成人欧美一区二区三区在线播放| 亚洲男人的天堂av| 亚洲成人免费影院| 麻豆精品一区二区| 国产成人亚洲综合a∨婷婷 | 在线观看91精品国产入口| 欧美系列一区二区| 日韩亚洲国产中文字幕欧美| 欧美va亚洲va香蕉在线| 国产精品福利影院| 日韩影院在线观看| 国产精品一二三在| 91久久人澡人人添人人爽欧美| 欧美欧美欧美欧美| 国产婷婷精品av在线| 亚洲人成网站在线| 日本欧美一区二区在线观看| 国产在线一区二区综合免费视频| 99久久久久久| 在线不卡中文字幕| 欧美国产在线观看| 亚洲国产精品久久久久秋霞影院| 精品综合久久久久久8888| 99综合电影在线视频| 3atv在线一区二区三区| 国产亚洲一区二区三区四区| 亚洲午夜电影在线| 国内精品在线播放| 欧美电影一区二区| 亚洲日本乱码在线观看| 精品一区二区三区久久| 色婷婷av一区二区| 国产丝袜在线精品| 蜜桃av一区二区在线观看| 一本色道亚洲精品aⅴ| 国产米奇在线777精品观看| 成人手机电影网| 日韩免费在线观看| 亚洲一线二线三线久久久| 久久国产精品区| 在线一区二区三区四区五区| 国产亚洲美州欧州综合国| 亚洲一区二区三区四区的| 成人免费毛片嘿嘿连载视频| 日韩欧美视频一区| 亚洲高清在线视频| 一本大道av一区二区在线播放| 久久久99久久| 久久国产精品色| 欧美一区二区网站| 午夜电影网一区| 欧美午夜一区二区三区 | www.亚洲在线| 中文字幕欧美日本乱码一线二线| 久久国产精品色婷婷| 91精品欧美一区二区三区综合在| 亚洲一区二区av在线| jizz一区二区| 国产精品视频一二三区| 国产盗摄精品一区二区三区在线| 日韩一区二区电影在线| 日韩黄色片在线观看| 欧美麻豆精品久久久久久| 亚洲与欧洲av电影| 欧美视频一区在线观看| 亚洲精品写真福利| 日本道免费精品一区二区三区| 最新日韩av在线| 一本大道久久a久久精二百| 亚洲欧洲av在线| 91丝袜美女网| 亚洲精品中文字幕在线观看| 91尤物视频在线观看| 亚洲免费视频中文字幕| 91麻豆免费看片| 亚洲午夜成aⅴ人片| 91久久一区二区| 调教+趴+乳夹+国产+精品| 日韩精品一区二区三区在线| 精品一区二区三区在线观看国产| 欧美xfplay| 成人永久aaa| 久久久久国产成人精品亚洲午夜| 午夜精品福利久久久| 日韩女优毛片在线| 免费看黄色91| 国产午夜精品一区二区三区视频| 国产一区高清在线| 亚洲精品伦理在线| 欧美日韩性生活| 国产一区二三区| 国产精品福利一区| 欧美美女直播网站| 国产一区二区三区日韩| 中文字幕一区二区不卡| 欧美久久久久久久久中文字幕| 老司机精品视频在线| 国产精品福利影院| 717成人午夜免费福利电影| 国产a精品视频| 2021国产精品久久精品| 91免费看视频| 美女mm1313爽爽久久久蜜臀| 日韩一级免费观看| 一本一本久久a久久精品综合麻豆| 一区二区国产视频| 久久久精品一品道一区| 在线观看亚洲精品| 久久精品国产精品亚洲精品| 亚洲欧洲日韩在线| 91精品免费在线| 色素色在线综合| 97久久精品人人做人人爽| 亚洲自拍偷拍综合| 亚洲国产精品传媒在线观看| 欧美高清激情brazzers| 成人手机在线视频| 国产在线精品视频| 婷婷综合在线观看| 最新高清无码专区| 国产精品福利av| 久久蜜桃一区二区| 欧美一区二区三区在线观看视频| 久久久久久免费网| 91精品国产91热久久久做人人 | 免费观看日韩av| 国产精品久久二区二区| 日韩三级视频在线看| 精品视频资源站| 国产盗摄女厕一区二区三区| 日本aⅴ免费视频一区二区三区| 国产精品短视频| 欧美精品一区二区三区在线播放| 欧美日韩精品三区| 欧美亚洲免费在线一区| 成人黄页毛片网站| 丰满少妇久久久久久久 | 在线欧美日韩国产| 99久久精品免费看国产免费软件| 免费人成精品欧美精品| 午夜精品一区二区三区三上悠亚| 成人欧美一区二区三区| 精品久久久久久无| 精品电影一区二区| 精品sm在线观看| 久久综合色婷婷| 欧美videos大乳护士334| 精品国产免费视频| 日韩女优毛片在线| 久久综合资源网| 久久精品一区二区三区av| 日韩免费在线观看| 久久一区二区三区四区| 久久久久久久网| 国产精品人成在线观看免费| 欧美激情一区二区三区在线| 欧美国产综合一区二区| 亚洲日本va在线观看| 亚洲精品久久久蜜桃| 亚洲成人久久影院| 精品一区二区综合| 成人v精品蜜桃久久一区| 94-欧美-setu| 777欧美精品| 久久午夜电影网| 国产精品麻豆一区二区| 亚洲国产成人av网| 国产又黄又大久久| 色吊一区二区三区| 精品久久国产老人久久综合| 国产调教视频一区| 性感美女极品91精品| 国内精品第一页| 色综合天天综合| 精品精品国产高清一毛片一天堂| 国产精品二三区| 蜜桃久久久久久久| 色老汉av一区二区三区| 日韩精品一区在线观看| 国产精品久久久久毛片软件| 亚洲男人的天堂av| 国产成人精品亚洲日本在线桃色 | 一区二区三区四区精品在线视频 | 欧美日韩小视频| 中文字幕av一区二区三区免费看 | 亚洲色图在线播放| 婷婷综合五月天|