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

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

?? gamemanager.java

?? J2ME MIDP_Example_Applications
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
// 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.Vector;
import javax.microedition.lcdui.*;


// GameManager is used by CloseableCanvas or NokiaCloseableCanvas.
// (BlockGameMIDlet creates a CloseableCanvas or NokiaCloseableCanvas
// depending on the capabilities of the MIDP device where the MIDlet
// was downloaded.)
//
// This GameManager tries to be as portable as possible. It doesn't
// use any drawing feature of the Nokia UI API's FullCanvas that an
// ordinary MIDP Canvas API doesn't support, other than the basic
// 'full canvas' property of FullCanvas.

class GameManager
    implements Runnable
{
    // When either side gets GAME_OVER_SCORE points, the game ends.
    final static int GAME_OVER_SCORE = 100;
    final static int MILLIS_PER_TICK = 250; // msec
    final static int MAX_CHANNELS = 8; // 8 channels of blocks
    final static int MAX_BLOCK_HEIGHT = 10; // 10 pixels
    final static int MAX_PLAYER_LIVES = 5; // 5 lives

    private final static int MAX_PIXELS = 200;
    private final static Font GAME_FONT =
        Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);

    private final int gameWidth;
    private final int gameHeight;
    private final BlockGameMIDlet midlet;
    private final Dictionary dict;
    private final Canvas canvas;
    private final Vector blocks = new Vector();
    private final Base base;
    private final DoublyLinkedList bullets = new DoublyLinkedList();
    private final GameEffects gameEffects;
    private final boolean useLimitedFiringRate;

    private volatile Thread animationThread = null;
    // hasBeenShown could be set by Canvas.showNotify()
    private boolean hasBeenShown = false;
    private volatile boolean isPaused = false;
    private boolean isGameOver = false;
    private int gameOverTicks = 0;
    private int baseScore = 0;
    private int blocksScore = 0;

    // The text labels for the player's score and the base's 'lives count',
    // take up a bit too much screen space on small displays. As the label
    // text itself is rather static, we only show the label text for
    // 'showLabelTicks' (7.5 seconds). Similarly, the base's 'lives count'
    // also changes slowly.
    private int showLabelTicks = (7500 / GameManager.MILLIS_PER_TICK);


    GameManager(BlockGameMIDlet midlet, Dictionary dict,
        GameEffects gameEffects, Canvas canvas)
    {
        this.midlet = midlet;
        this.dict = dict;
        this.canvas = canvas;
        this.gameEffects = gameEffects;

        useLimitedFiringRate = midlet.useLimitedFiringRate();

        // Limit the maximum size of the game to be 200 x 200 pixels.
        // This is for better game play on MIDP devices with a larger
        // resolution. (For example on devices which are very much wider
        // than long, it otherwise takes too long for the blocks to fly from
        // right to left, and for the bullets to fly from left to right.)
        gameWidth  = (canvas.getWidth() < MAX_PIXELS) ?
                     canvas.getWidth() : MAX_PIXELS;
        gameHeight = (canvas.getHeight() < MAX_PIXELS) ?
                     canvas.getHeight() : MAX_PIXELS;


        // A block is a square that is 'dimension' pixels high
        // and 'dimension' pixels wide. The dimension of a block
        // is one of the basic properties which affects how the game
        // looks. (Note: the base's size also depends on this parameter
        // as we'd like the base and blocks to be about the same size.)
        //
        // The screen height is divided into 'MAX_CHANNELS' or less channels.
        // The blocks fly left down the channels. The following figure
        // helps to illustrate:
        //   --------------------------------------------
        //      yOffset |                       ^
        //              +---+  ^                | channelHeight
        //              +   +  | blockHeight    |
        //              +---+  v                |
        //                                      v
        //   ----------------------------------------------
        // There is one block per channel.

        int numChannels = MAX_CHANNELS;

        if (gameHeight < gameWidth)
        {
            numChannels = (gameHeight * numChannels) / gameWidth;
        }

        int channelHeight = gameHeight / numChannels;
        // Set the blockHeight to be 70 % of channelHeight
        // to leave some space between blocks.
        int blockHeight = ((70 * channelHeight) / 100);
        int yOffset = (channelHeight - blockHeight) / 2;

        if ((numChannels < MAX_CHANNELS) &&
            (blockHeight < MAX_BLOCK_HEIGHT))
        {
            // For smaller screens, the blockHeight (dimension) should
            // be at least some minimum pixel size, otherwise the blocks
            // and base feel too small.

            // channel height equals block height
            blockHeight = MAX_BLOCK_HEIGHT;
            numChannels = gameHeight / blockHeight;
            yOffset = 0;
        }
        Block.setDimension(blockHeight); // set dimension for all Blocks


        // Picking a dx value that is independent of gameWidth + blockWidth
        // and that works well for a variety of screen sizes is a bit tricky,
        // because for the smallest device screen widths the game uses
        // a minimum pixel size (which may also reduce the number
        // of channels) rather than a constant ratio of blockWidth to
        // gameWidth for all screen sizes. Also, on taller screens
        // the user may have to spend more time moving up and down
        // than on shorter screens (e.g. if there are 8 channels of blocks
        // rather than 6 channels on a smaller device). This is result of not
        // making the game scale proportional to the height and width of
        // the screen, for all possible screen sizes.
        //
        // The block speed should not be either annoyingly fast or slow
        // on a range of real devices.

        int dx;

        if (numChannels < MAX_CHANNELS)
        {
            dx = -(gameWidth / (3 * Block.getDimension()));
        }
        else
        {
            dx = -(gameWidth / (4 * Block.getDimension()));
        }
        if (dx == 0)
        {
            dx = -1;
        }

        for (int channel = 0; channel < numChannels; channel++)
        {
            Block block = new Block(this, 0, gameWidth,
                (yOffset + (channel * channelHeight)), dx);

            blocks.addElement(block);
        }

        int playerLives = MAX_PLAYER_LIVES;

        base = new Base(this, useLimitedFiringRate, playerLives, 0, 0,
                        gameWidth, gameHeight);
    }


    boolean isGameOver()
    {
        return isGameOver;
    }


    private boolean baseIsWinning()
    {
        return ((base.getLives() > 0) && (baseScore >= blocksScore));
    }


    private void tick()
    {
        if (isGameOver)
        {
            // 1) The game is over.

            // When the game is over, wait 30 seconds before stopping the
            // animation thread. This gives the draw method a chance to wait
            // a few seconds before displaying a message that prompts the user
            // to press a softkey to return to the MainMenu. It also gives the
            // 'game over' tune some time to play.)
            if (gameOverTicks < (30000 / MILLIS_PER_TICK))
            {
                gameOverTicks++;

                // When the game is over, wait 1 second before playing
                // the game over music
                if (gameEffects.hasSoundCapability() &&
                    (gameOverTicks == (1000 / MILLIS_PER_TICK)))
                {
                    boolean hasPlayerWon = (baseScore >= blocksScore);

                    gameEffects.playGameOverMusic(hasPlayerWon);
                }
            }
            else
            {
                // 30 seconds has passed, stop the animation thread, etc.
                stop();
            }
        }
        else if ((base.getLives() == 0) || (baseScore >= GAME_OVER_SCORE) ||
            (blocksScore >= GAME_OVER_SCORE))
        {
            // 2) Detect and set the 'game over' state.

            // Setting isGameOver to 'true' causes the 'if (isGameOver)'
            // block of code above, to be executed on subsequent ticks.

            isGameOver = true;
            gameOverTicks = 0;
        }
        else
        {
            // 3) The game is still playing.

            // showLabelTicks is used by the draw method to print
            // longer or shorter text messages indicating the current score,
            // lives, etc. When the game first starts, longer versions
            // (with explanatory labels) are printed. When the tick
            // counts reach zero, shorter versions are printed
            // (so more of the screen is visible during playing of the game).
            if (showLabelTicks > 0)
            {
                showLabelTicks--;
            }

            // Base tick
            base.tick();


            // Bullets' ticks
            Bullet b = (Bullet) (bullets.getFirst());
            Bullet prev = null;

            while (b != null)
            {
                b.tick();
                prev = b;
                b = (Bullet) (bullets.getNext(b));
                if (!prev.isActive())
                {
                    bullets.remove(prev);
                }
            }

            // Blocks' ticks
            for (int ix = 0; ix < blocks.size(); ix++)
            {
                Block block = (Block) blocks.elementAt(ix);

                block.tick();

                // Check for bullet collisions
                b = (Bullet) (bullets.getFirst());
                while (b != null)
                {
                    if (block.isCollision(b))
                    {
                        if (block.doBulletCollision())
                        {
                            // true: the block exploded in the collision

                            baseScore += block.getPoints();
                            block.updateStrength(); // stronger next life
                            gameEffects.playBlockExplosion();
                        }
                        b.doExplode();
                    }
                    b = (Bullet) (bullets.getNext(b));
                }

                // Check for base collisions
                if (block.isCollision(base))
                {
                    int lives = base.getLives();

                    if (!base.isColliding())
                    {
                        // If the base is not already colliding with
                        // another block and is colliding with this block,
                        // then handle the base collision:
                        //   - inform base of collision
                        //   - get new 'base lives' count
                        //   - use GameEffects for explode noise + vibrate
                        base.doCollision();
                        gameEffects.playBaseExplosion();
                        gameEffects.vibrate();
                    }

                    // Handle block collision:
                    //   Blocks get more points for hitting the base,
                    //   than vice versa. Blocks get extra points
                    //   for completely destroying base (no lives left).
                    baseScore += block.getPoints();
                    if (lives == 0)
                    {
                        blocksScore += 20;
                    }
                    else
                    {
                        blocksScore += (2 * block.getPoints());
                    }
                    block.doExplode();
                    block.updateStrength(); // A stronger next life
                }
            }
        }
    }


    // Canvas methods

    public void paint(Graphics g)
    {
        if (isGameOver)
        {
            // Print an appropriate 'game over' message.

            int color;
            String winnerText;

            if (baseIsWinning())
            {
                color = Base.COLOR;
                winnerText = dict.getString(Dictionary.TEXT_GAME_YOU_WON);
            }
            else
            {
                color = Block.COLOR;
                winnerText = dict.getString(Dictionary.TEXT_GAME_YOU_LOST);
            }


            String lastText = null; // last line's default message

            if (gameOverTicks < (4000 / MILLIS_PER_TICK))
            {
                if (base.getLives() == 0)
                {
                    lastText =
                        dict.getString(Dictionary.TEXT_GAME_BASE_DESTROYED);
                }
            }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re成人精品视频| 麻豆成人免费电影| 三级成人在线视频| 激情五月激情综合网| aaa亚洲精品一二三区| 欧美视频中文一区二区三区在线观看 | 国产一区不卡视频| av福利精品导航| 91麻豆精品国产91久久久资源速度| 久久久久久日产精品| 一区二区欧美视频| 国产一区二区精品久久91| 91免费国产在线观看| 日韩欧美在线123| 亚洲日韩欧美一区二区在线| 美女在线视频一区| www.成人在线| 日韩精品中文字幕一区| 国产精品第五页| 精品一二线国产| 欧美亚洲尤物久久| 国产精品久久久久影院老司| 麻豆91免费看| 欧美日韩一级黄| 成人欧美一区二区三区白人| 九九精品一区二区| 欧美日韩久久一区| 自拍偷自拍亚洲精品播放| 精品一区二区三区欧美| 欧洲一区二区三区在线| 国产精品三级av在线播放| 秋霞av亚洲一区二区三| 日本精品视频一区二区三区| 精品剧情在线观看| 日日噜噜夜夜狠狠视频欧美人| 成人免费毛片高清视频| 欧美成人vr18sexvr| 亚洲宅男天堂在线观看无病毒| 国产福利视频一区二区三区| 欧美男人的天堂一二区| 亚洲欧美日韩国产中文在线| 国产剧情av麻豆香蕉精品| 欧美剧情电影在线观看完整版免费励志电影| 亚洲国产高清在线| 狠狠色丁香久久婷婷综合_中| 欧美色国产精品| 一区二区三区自拍| 99精品视频一区二区| 国产无遮挡一区二区三区毛片日本| 日韩二区三区四区| 欧美欧美欧美欧美| 亚洲 欧美综合在线网络| 91色porny| 一色屋精品亚洲香蕉网站| 国产精品亚洲一区二区三区在线 | 婷婷六月综合亚洲| 欧美色视频在线| 亚洲一二三区在线观看| 欧洲国内综合视频| 亚洲欧美日韩在线| 91麻豆国产福利在线观看| 亚洲视频 欧洲视频| 色综合久久综合网97色综合| 中文成人综合网| 北条麻妃国产九九精品视频| 国产日韩欧美高清在线| 国产成人激情av| 国产精品免费久久| 99久久精品99国产精品| 自拍偷拍亚洲综合| 99国内精品久久| 一区二区三区在线视频观看| 日本二三区不卡| 亚洲一区二区三区影院| 欧美日韩一本到| 舔着乳尖日韩一区| 日韩一级精品视频在线观看| 久久精品国产一区二区三区免费看| 日韩视频一区二区| 国产美女娇喘av呻吟久久| 久久精品水蜜桃av综合天堂| 国产成人免费视| 亚洲视频一区在线观看| 欧美探花视频资源| 日韩二区三区在线观看| 欧美精品一区二区三区四区| 国产高清久久久久| 亚洲人吸女人奶水| 欧美视频你懂的| 精品在线你懂的| 国产午夜久久久久| 91麻豆蜜桃一区二区三区| 亚洲最大成人综合| 69堂国产成人免费视频| 久久精品国产网站| 欧美国产乱子伦| 色综合中文字幕国产 | 在线观看一区不卡| 日本亚洲欧美天堂免费| 91亚洲精品久久久蜜桃| 午夜在线成人av| 日韩视频永久免费| 成人国产精品免费观看视频| 亚洲一线二线三线视频| 日韩美女一区二区三区四区| 成人免费不卡视频| 天堂午夜影视日韩欧美一区二区| 精品久久久久久亚洲综合网| 成人小视频免费观看| 亚洲午夜在线观看视频在线| 亚洲精品一线二线三线无人区| 成人毛片视频在线观看| 首页国产欧美久久| 中文字幕不卡在线观看| 欧美浪妇xxxx高跟鞋交| 国产黑丝在线一区二区三区| 亚洲午夜久久久久久久久电影网| 日韩精品一区二区三区中文不卡| 成人永久aaa| 午夜精品一区二区三区三上悠亚| 久久久久久夜精品精品免费| 欧美制服丝袜第一页| 国产一区二区三区综合| 亚洲午夜精品久久久久久久久| 精品美女在线播放| 欧美系列亚洲系列| 懂色av中文字幕一区二区三区| 亚洲高清免费观看高清完整版在线观看 | 国产精品久久久一区麻豆最新章节| 欧美日韩一区二区不卡| 粉嫩aⅴ一区二区三区四区五区 | 91麻豆精品国产91久久久更新时间 | 欧美一区在线视频| 99精品国产99久久久久久白柏| 免费成人在线观看| 亚洲综合免费观看高清完整版在线| 欧美tickle裸体挠脚心vk| 欧美亚洲动漫精品| 波多野结衣一区二区三区| 日本aⅴ免费视频一区二区三区| 亚洲欧美视频在线观看视频| 欧美精品一区二区三区很污很色的| 欧美午夜精品一区二区三区| 国产91色综合久久免费分享| 亚洲成人黄色影院| 中文字幕综合网| 国产欧美久久久精品影院| 欧美一区二区日韩| 色婷婷av一区二区三区软件| 国产成人一区二区精品非洲| 人人精品人人爱| 亚洲成人黄色影院| 玉米视频成人免费看| 中文字幕一区在线观看视频| 2欧美一区二区三区在线观看视频| 在线成人高清不卡| 欧美性xxxxxx少妇| 色猫猫国产区一区二在线视频| 成人性生交大合| 精品一区二区精品| 久久精品免费看| 免费视频一区二区| 欧美aaaaaa午夜精品| 亚洲成av人片在线观看无码| 亚洲欧美成人一区二区三区| 国产香蕉久久精品综合网| 精品剧情在线观看| 欧美成人精品福利| 精品国产一区二区三区不卡| 555夜色666亚洲国产免| 欧美日韩一区二区在线观看| 欧美性色aⅴ视频一区日韩精品| 97久久超碰精品国产| 成人不卡免费av| 成人丝袜18视频在线观看| 粉嫩av一区二区三区在线播放| 国产高清视频一区| 成人午夜电影小说| 成人av片在线观看| 99天天综合性| 99久久夜色精品国产网站| 成人av高清在线| 色综合久久综合中文综合网| 一本大道久久a久久精二百 | 夜夜嗨av一区二区三区四季av| 亚洲摸摸操操av| 一区二区三区在线观看国产| 亚洲色图欧美激情| 亚洲精品v日韩精品| 一区二区三区国产精华| 亚洲一区二区三区四区不卡| 亚洲成a人v欧美综合天堂| 亚洲第一狼人社区| 日韩电影免费在线看| 裸体歌舞表演一区二区| 韩国成人精品a∨在线观看| 床上的激情91.| 97久久超碰精品国产| 欧美影片第一页| 9191精品国产综合久久久久久|