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

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

?? block.java

?? J2ME MIDP_Example_Applications
?? JAVA
字號:
// Copyright 2003 Nokia Corporation.
//
// THIS SOURCE CODE IS PROVIDED 'AS IS', WITH NO WARRANTIES WHATSOEVER,
// EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY, FITNESS
// FOR ANY PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE
// OR TRADE PRACTICE, RELATING TO THE SOURCE CODE OR ANY WARRANTY OTHERWISE
// ARISING OUT OF ANY PROPOSAL, SPECIFICATION, OR SAMPLE AND WITH NO
// OBLIGATION OF NOKIA TO PROVIDE THE LICENSEE WITH ANY MAINTENANCE OR
// SUPPORT. FURTHERMORE, NOKIA MAKES NO WARRANTY THAT EXERCISE OF THE
// RIGHTS GRANTED HEREUNDER DOES NOT INFRINGE OR MAY NOT CAUSE INFRINGEMENT
// OF ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OWNED OR CONTROLLED
// BY THIRD PARTIES
//
// Furthermore, information provided in this source code is preliminary,
// and may be changed substantially prior to final release. Nokia Corporation
// retains the right to make changes to this source code at
// any time, without notice. This source code is provided for informational
// purposes only.
//
// Nokia and Nokia Connecting People are registered trademarks of Nokia
// Corporation.
// Java and all Java-based marks are trademarks or registered trademarks of
// Sun Microsystems, Inc.
// Other product and company names mentioned herein may be trademarks or
// trade names of their respective owners.
//
// A non-exclusive, non-transferable, worldwide, limited license is hereby
// granted to the Licensee to download, print, reproduce and modify the
// source code. The licensee has the right to market, sell, distribute and
// make available the source code in original or modified form only when
// incorporated into the programs developed by the Licensee. No other
// license, express or implied, by estoppel or otherwise, to any other
// intellectual property rights is granted herein.


import java.util.Random;
import javax.microedition.lcdui.*;


// Blocks try to fly past the base, or crash into it.
// A Block can draw itself.

class Block
{
    final static int COLOR = 0xFFFFFF; // WHITE

    private final static int MIN_STRENGTH = 0; // bulletStrength
    private final static int MAX_STRENGTH = 5; // bulletStrength
    private final static int COLLIDE_BORDER = 2; // pixels
    private final static Random random = new Random();

    private final GameManager gameManager;
    private final int xMin;
    private final int xMax;
    private final int dx;
    private final int dxRandom;

    private static int dimension = 10; // default height/width in pixels
    private int dxVariable = 0;

    // A dormant block is one that has been temporarily removed from
    // the game, for example before beginning a new life.
    // When created, each block is dormant for 1.5 seconds before
    // joining the game.
    private int dormantTicks = (1500 / GameManager.MILLIS_PER_TICK);

    private int bulletHits = 0;
    private int bulletStrength = MIN_STRENGTH;
    private int x;
    private int y;


    Block(GameManager gameManager, int xMin, int xMax, int y, int dx)
    {
        this.gameManager = gameManager;
        this.xMin = xMin;
        this.xMax = xMax;
        this.y = y;

        // Set the fixed velocity component, and the default
        // variable velocity component (based on the fixed velocity).
        // Method varySpeed modifies the variable velocity component based
        // on block strength. It modifies the variable component of the
        // block speed so that as a block becomes stronger, the variable
        // component of speed becomes weaker.
        this.dx = dx;
        dxRandom = -rand(dx);
        varySpeed();

        bulletHits = 0;
        x = xMax - dimension;
    }


    private void varySpeed()
    {
        // Stronger blocks should have a 'tendency' to move
        // more slowly than weaker ones move. (Most may move
        // somewhat more slowly, but not in all cases.)
        dxVariable = ((MAX_STRENGTH - bulletStrength) * dxRandom) /
                     MAX_STRENGTH;
    }


    static void setDimension(int d)
    {
        dimension = d;
    }


    static int getDimension()
    {
        return dimension;
    }


    public void tick()
    {
        if (dormantTicks > 0)
        {
            // dormant blocks wait awhile before re-entering the game
            dormantTicks--;
        }
        else
        {
            // check if we moved off the left game edge
            if (x <= xMin)
            {
                gameManager.doBlockPassed(this);

                // become dormant for 3 seconds
                dormantTicks = (3000 / GameManager.MILLIS_PER_TICK);
                x = xMax - dimension; // initialize re-start x position
                if (bulletHits == 0)
                {
                    // If the block flew off canvas without having been shot,
                    // increase it's strength so it's more difficult to
                    // destroy in it's next life.
                    updateStrength();

                    varySpeed(); // change the variable component of speed
                }
                else
                {
                    // Reset strength and hits, to become a weak block.
                    bulletStrength = 0;
                    bulletHits = 0;

                    varySpeed(); // change the variable component of speed
                }
            }
            else
            {
                int gw = gameManager.getCanvas().getWidth();

                // The block moves left (dx + dxVariable is negative)
                x += (dx + dxVariable);
            }
        }
    }


    public void draw(Graphics g)
    {
        if (dormantTicks == 0)
        {
            int d = dimension;
            int rx = x;
            int ry = y;


            // Different blocks are drawn for bulletStrength 0 .. 5:
            //   0 : dark block with white pixel border, no diagonals
            //   1 : dark block with white pixel border, 1 white diagonal line
            //   2 : dark block with white pixel border, 2 white diagonal lines
            //   3 : white filled block with no diagonals
            //   4 : white filled block with one dark diagonal line
            //   5 : white filled block with two dark diagonal line

            g.setColor(COLOR);
            if (bulletStrength < 3)
            {
                g.drawRect(rx, ry, (d - 1), (d - 1));
                if (bulletStrength > 0)
                {
                    g.drawLine((rx + d - 1), ry, rx, (ry + d - 1));
                }
                if (bulletStrength > 1)
                {
                    g.drawLine(rx, ry, (rx + d - 1), (ry + d - 1));
                }
            }
            else
            {
                g.fillRect(rx, ry, d, d);
                g.setColor(0x000000); // BLACK
                if (bulletStrength > 3)
                {
                    g.drawLine((rx + d - 2), (ry + 1), (rx + 1), (ry + d - 2));
                }
                if (bulletStrength > 4)
                {
                    g.drawLine((rx + 1), (ry + 1), (rx + d - 2), (ry + d - 2));
                }
            }
        }
    }


    // Increase the bullet strength of the Block up to a maximum strength,
    // but reset to initial value if update would be more than the maximum.
    void updateStrength()
    {
        if (bulletStrength <= MAX_STRENGTH)
        {
            bulletStrength++;
        }
        else if (bulletStrength > MAX_STRENGTH)
        {
            bulletStrength = MIN_STRENGTH;
        }
    }


    int getPoints()
    {
        // The 'points' value of a block is based on its strength
        return (bulletStrength + 1);
    }


    boolean isCollision(Bullet b)
    {
        boolean overlaps = overlaps2D(x, y, dimension, dimension,
                                      b.getX(), b.getY(), b.getWidth(),
                                      b.getHeight());
        return ((dormantTicks == 0) && overlaps);
    }


    boolean isCollision(Base b)
    {
        // Using a phone keypad to control the {x, y} position
        // of the base may not give the player sufficient fine grained
        // control of position as they might like. One way to improve
        // this is to make the Block/Base collision detection less sensitive.
        //
        // The COLLIDE_BORDER parameter allows the collision detection
        // to be slightly more forgiving than an exact overlap.

        boolean overlaps = overlaps2D((x + COLLIDE_BORDER),
                                      (y + COLLIDE_BORDER),
                                      (dimension - (2 * COLLIDE_BORDER)),
                                      (dimension - (2 * COLLIDE_BORDER)),
                                      b.getX(),
                                      b.getY(),
                                      (b.getWidth() + b.getCannonDimension()),
                                      b.getHeight());

        return ((dormantTicks == 0) && overlaps);
    }


    boolean doBulletCollision()
    {
        if (++bulletHits > bulletStrength)
        {
            doExplode();
            return true; // block exploded
        }
        return false;
    }


    void doExplode()
    {
        dormantTicks = 30; // Remove from game for 30 ticks

        // Re-initialize some block parameters
        bulletHits = 0;
        x = xMax - dimension;
    }


    // Do two rectangles overlap?
    private static boolean overlaps2D(int x1, int y1, int w1, int h1,
        int x2, int y2, int w2, int h2)
    {
        return overlaps1D(x1, w1, x2, w2) && overlaps1D(y1, h1, y2, h2);
    }


    // Do two lines overlap?
    private static boolean overlaps1D(int p1, int l1, int p2, int l2)
    {
        return (p1 <= p2) ? ((p1 + l1) >= p2) : (p1 <= (p2 + l2));
    }


    // Return a positive random-like number
    private static int rand(int scale)
    {
        return (random.nextInt() << 1 >>> 1) % scale;
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
视频一区二区欧美| 制服丝袜日韩国产| 天天综合色天天综合色h| 日韩一级完整毛片| 99热在这里有精品免费| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美精品一区二区在线播放| 91丝袜美女网| 国产一区二区伦理片| 亚洲一区二区精品久久av| 亚洲国产精品激情在线观看| 91精品国产品国语在线不卡| 91蝌蚪porny九色| 国产成人鲁色资源国产91色综| 秋霞影院一区二区| 亚洲一区在线电影| 亚洲视频每日更新| 久久色中文字幕| 欧美成人一区二区三区片免费| 日本韩国欧美三级| 成人99免费视频| 色综合久久久网| 91网站最新地址| 日本高清免费不卡视频| www.亚洲激情.com| 91麻豆高清视频| 91久久精品一区二区三| 91黄色免费版| 欧美日本精品一区二区三区| 欧美伦理电影网| 日韩免费高清电影| 久久老女人爱爱| 国产日韩精品久久久| 亚洲国产精品成人久久综合一区| ww亚洲ww在线观看国产| 国产女人18水真多18精品一级做| 久久精品日韩一区二区三区| 中文字幕乱码日本亚洲一区二区 | 欧美日韩一区二区欧美激情| 欧美日韩国产高清一区二区三区 | 国产精品免费aⅴ片在线观看| 中文字幕视频一区| 日韩和欧美一区二区三区| 蜜臀av一区二区在线观看| 成人一二三区视频| 欧美性videosxxxxx| 久久综合色鬼综合色| 亚洲一区二区三区四区在线观看| 亚洲一二三专区| 国产又黄又大久久| 在线观看日韩一区| 久久久精品日韩欧美| 亚洲码国产岛国毛片在线| 秋霞av亚洲一区二区三| 成人高清视频在线| 精品欧美乱码久久久久久 | 成人性视频网站| 欧美一区二区三区男人的天堂| 亚洲国产高清在线| 日本不卡1234视频| 欧美亚一区二区| 国产精品理伦片| 高清久久久久久| 欧美mv日韩mv国产网站| 午夜精品久久久久久久99水蜜桃 | 国产精品911| 日韩一级免费一区| 日本成人在线一区| 色婷婷av一区二区三区软件| 国产女主播视频一区二区| 精品无人码麻豆乱码1区2区| 色悠久久久久综合欧美99| 欧美变态tickling挠脚心| 亚洲乱码国产乱码精品精可以看| 韩国精品一区二区| 国产成人三级在线观看| 欧美日韩国产首页| 午夜免费久久看| 欧美精品久久久久久久多人混战| 婷婷久久综合九色国产成人 | 国产欧美日韩视频一区二区| 日韩精品亚洲专区| 欧美一区二区三级| 精品综合免费视频观看| 久久久精品tv| 99re热视频精品| 亚洲一区二区在线观看视频| 在线观看亚洲一区| 日韩高清在线观看| 日韩精品一区二区三区三区免费| 久久激情五月激情| 亚洲国产成人在线| 欧美日韩国产综合一区二区三区| 美女脱光内衣内裤视频久久影院| 国产亚洲精品aa午夜观看| 99久久亚洲一区二区三区青草| 亚洲自拍都市欧美小说| 日韩一区二区高清| 色婷婷激情久久| 国产乱码精品一区二区三区忘忧草 | 国产婷婷色一区二区三区在线| 粉嫩蜜臀av国产精品网站| 一区二区三区在线视频免费观看| 7777女厕盗摄久久久| 99re6这里只有精品视频在线观看| 亚洲一区在线播放| 日韩一区在线看| 久久久天堂av| 日韩欧美卡一卡二| 91国产精品成人| 成人黄页在线观看| 精品一区精品二区高清| 一区二区免费在线| 亚洲图片欧美激情| 国产日韩欧美在线一区| 欧美变态tickling挠脚心| 99精品热视频| 93久久精品日日躁夜夜躁欧美| 精品无人码麻豆乱码1区2区 | 国产精品初高中害羞小美女文| 日韩欧美资源站| 日韩亚洲欧美在线观看| 欧美日韩精品一区二区三区蜜桃| 色综合天天做天天爱| www.久久精品| 成人av在线资源| 99久久精品国产一区二区三区 | 精品一区二区三区视频| 亚洲午夜久久久| 天天色 色综合| 五月综合激情网| 免播放器亚洲一区| 国内精品嫩模私拍在线| 国产精品自拍三区| 成人av动漫网站| 欧美丝袜第三区| 日韩一卡二卡三卡国产欧美| 久久亚洲精华国产精华液| 中文在线一区二区| 亚洲一卡二卡三卡四卡五卡| 丝袜亚洲另类欧美| 国产精品资源在线| 91丨porny丨中文| 日韩你懂的在线播放| 久久久精品国产99久久精品芒果 | 精品一区在线看| 97se狠狠狠综合亚洲狠狠| 欧美群妇大交群中文字幕| 精品国产乱码久久久久久浪潮| 国产精品午夜在线观看| 亚洲一区二区三区激情| 国产一区二区在线观看视频| 成人免费高清在线| 欧美精品久久久久久久多人混战| 久久男人中文字幕资源站| 亚洲激情图片小说视频| 免费成人av资源网| 91蝌蚪porny成人天涯| 精品久久久三级丝袜| 亚洲一区二区三区小说| 成人一区二区三区视频在线观看| 欧美日本韩国一区二区三区视频| 国产精品乱码一区二三区小蝌蚪| 亚洲高清久久久| 99riav久久精品riav| 久久九九久精品国产免费直播| 午夜欧美2019年伦理| 日本道精品一区二区三区 | 日本成人在线看| 欧美色男人天堂| 亚洲三级久久久| av不卡在线播放| 中文字幕亚洲区| 成人免费毛片片v| 日本一区二区三区高清不卡 | 在线观看精品一区| 亚洲精品成人精品456| 91在线观看高清| 亚洲一区二区在线播放相泽| 911精品国产一区二区在线| 亚洲在线成人精品| 欧美在线观看一区| 日本欧美大码aⅴ在线播放| 在线观看亚洲精品| 日韩精品一卡二卡三卡四卡无卡| 欧美日韩一卡二卡三卡| 污片在线观看一区二区| 91精品国产综合久久久蜜臀粉嫩| 日本午夜精品一区二区三区电影| 欧美午夜一区二区| 卡一卡二国产精品| 久久一区二区三区国产精品| 成人免费av资源| 樱花草国产18久久久久| 欧美日韩一级二级| 国产精品一品二品| 亚洲无人区一区| 久久久久久久久久久久久久久99| 99精品欧美一区二区三区小说| 亚洲成人你懂的|