⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enemy.java

📁 j2me游戏都市骑士的代码,是一款横版格斗的游戏.可以学习参考.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:

            case 27: // '\033'
                switch(fr)
                {
                case 0: // '\0'
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawImage(game.dieIm, (x + game.x1 + game.dieIm.getWidth() / 2) - 28 - 112, (y + game.dieIm.getHeight() / 2) - 24 - 48, 1 | 2);
                    fr++;
                    break;

                case 1: // '\001'
                    y = 176;
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawImage(game.dieIm, (x + game.x1 + game.dieIm.getWidth() / 2) - 28 - 56, (y + game.dieIm.getHeight() / 2) - 24 - 48, 1 | 2);
                    fr++;
                    break;

                case 2: // '\002'
                    char c = '\310';
                    g.setClip((x - 28) + game.x1, c - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, c - 24, 56, 48);
                    g.drawImage(game.dieIm, (x + game.x1 + game.dieIm.getWidth() / 2) - 28, (c + game.dieIm.getHeight() / 2) - 24 - 48, 1 | 2);
                    if(System.currentTimeMillis() % 5L == 0L)
                    {
                        fr = 0;
                        ebackAttack = false;
                        ehit = false;
                        face = 26;
                    }
                    break;
                }
                break;

            case 26: // '\032'
                switch(fr)
                {
                default:
                    break label0;

                case 0: // '\0'
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawRegion(game.dieIm, 112, 48, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                    fr++;
                    break label0;

                case 1: // '\001'
                    y = 176;
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawRegion(game.dieIm, 56, 48, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                    fr++;
                    break label0;

                case 2: // '\002'
                    char c1 = '\310';
                    g.setClip((x - 28) + game.x1, c1 - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, c1 - 24, 56, 48);
                    g.drawRegion(game.dieIm, 56, 48, 56, 48, 2, (x - 28) + game.x1, c1 - 24, 0x10 | 4);
                    break;
                }
                if(System.currentTimeMillis() % 5L == 0L)
                {
                    fr = 0;
                    ebackAttack = false;
                    ehit = false;
                    face = 27;
                }
                break;
            }
    }

    public void enemyHitted(Graphics g)
    {
        if(ehit)
            if(!isWeapon)
                switch(face)
                {
                case 26: // '\032'
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawRegion(game.dieIm, 112, 48, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                    break;

                case 27: // '\033'
                    g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                    g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                    g.drawImage(game.dieIm, (x + game.x1 + game.dieIm.getWidth() / 2) - 28 - 112, (y + game.dieIm.getHeight() / 2) - 24 - 48, 1 | 2);
                    break;
                }
            else
            if(weapon == 41)
                switch(face)
                {
                case 27: // '\033'
                    g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                    g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                    g.drawRegion(game.chainIm, 204, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                    break;

                case 26: // '\032'
                    g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                    g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                    g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 204, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                    break;
                }
            else
            if(weapon == 39)
                switch(face)
                {
                case 26: // '\032'
                    g.setClip((x - 32) + game.x1, y - 36, 64, 72);
                    g.clipRect((x - 32) + game.x1, y - 36, 64, 72);
                    g.drawRegion(game.axeIm, 128, 72, 64, 72, 2, (x - 32) + game.x1, y - 36, 0x10 | 4);
                    break;

                case 27: // '\033'
                    g.setClip((x - 32) + game.x1, y - 36, 64, 72);
                    g.clipRect((x - 32) + game.x1, y - 36, 64, 72);
                    g.drawImage(game.axeIm, (((x + game.x1) - 32) + game.axeIm.getWidth() / 2) - 128, ((y - 36) + game.axeIm.getHeight() / 2) - 72, 1 | 2);
                    break;
                }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
        if(enemyCtr % 5 == 0)
            ehit = false;
    }

    public void enemyChainWalk(Graphics g)
    {
        switch(face)
        {
        default:
            break;

        case 26: // '\032'
            switch(fr)
            {
            case 0: // '\0'
                if(System.currentTimeMillis() - e_lag >= 2000L && y < emaxY - 15 - 2)
                    y -= 10;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 272, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;

            case 1: // '\001'
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 340, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;
            }
            break;

        case 27: // '\033'
            switch(fr)
            {
            default:
                break;

            case 0: // '\0'
                if(System.currentTimeMillis() - e_lag >= 2000L && y < emaxY - 15 - 2)
                    y -= 10;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 272, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;

            case 1: // '\001'
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 340, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;
            }
            break;
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

    public void enemyChainJump(Graphics g)
    {
        switch(face)
        {
        default:
            break;

        case 27: // '\033'
            switch(echainJumpCtr)
            {
            case 0: // '\0'
            case 1: // '\001'
                x += 3;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 204, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;

            case 2: // '\002'
            case 3: // '\003'
            case 4: // '\004'
                x += 4;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 204, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;

            case 5: // '\005'
            case 6: // '\006'
                x += 3;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 340, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;

            case 7: // '\007'
            case 8: // '\b'
            case 9: // '\t'
                x += 4;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawRegion(game.chainIm, 340, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                break;
            }
            break;

        case 26: // '\032'
            switch(echainJumpCtr)
            {
            case 0: // '\0'
            case 1: // '\001'
                x -= 3;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 204, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;

            case 2: // '\002'
            case 3: // '\003'
            case 4: // '\004'
                x -= 4;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 204, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;

            case 5: // '\005'
            case 6: // '\006'
                x -= 3;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 340, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;

            case 7: // '\007'
            case 8: // '\b'
            case 9: // '\t'
                x -= 4;
                g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 340, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                break;
            }
            break;
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

    public void drawChainFight(Graphics g)
    {
        if(weapon == 41)
            if(action == 15)
                switch(face)
                {
                case 26: // '\032'
                    switch(fr)
                    {
                    case 0: // '\0'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, ((x + game.x1) - 34) + game.chainIm.getWidth() / 2, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;

                    case 1: // '\001'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 136, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;

                    case 2: // '\002'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 204, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;

                    case 3: // '\003'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 272, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;

                    case 4: // '\004'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 340, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;
                    }
                    g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                    break;

                case 27: // '\033'
                    switch(fr)
                    {
                    case 0: // '\0'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 0, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;

                    case 1: // '\001'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 136, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;

                    case 2: // '\002'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 204, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;

                    case 3: // '\003'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 272, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;

                    case 4: // '\004'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 340, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;
                    }
                    g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                    break;
                }
            else
            if(action == 17)
                switch(face)
                {
                default:
                    break;

                case 26: // '\032'
                    switch(fr)
                    {
                    case 0: // '\0'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, ((x + game.x1) - 34) + game.chainIm.getWidth() / 2, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;

                    case 1: // '\001'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 204, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;
                    }
                    g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                    break;

                case 27: // '\033'
                    switch(fr)
                    {
                    case 0: // '\0'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawRegion(game.chainIm, 0, 64, 68, 64, 2, (x - 34) + game.x1, y - 32, 0x10 | 4);
                        break;

                    case 1: // '\001'
                        g.setClip((x - 34) + game.x1, y - 32, 68, 64);
                        g.clipRect((x - 34) + game.x1, y - 32, 68, 64);
                        g.drawImage(game.chainIm, (((x + game.x1) - 34) + game.chainIm.getWidth() / 2) - 204, ((y - 32) + game.chainIm.getHeight() / 2) - 64, 1 | 2);
                        break;
                    }
                    g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                    break;
                }
    }

    short x;
    short y;
    byte face;
    byte fr;
    short health;
    byte action;
    boolean isWeapon;
    boolean ehit;
    boolean ebackAttack;
    boolean emoving;
    Game game;
    byte weapon;
    short Dist;
    short emaxY;
    short enemyCtr;
    short ehitCtr;
    short ecrouchCtr;
    boolean eweaponPicked;
    boolean ecrouchHit;
    boolean playerHit;
    byte jpCtr;
    long e_lag;
    byte echainJumpCtr;
    byte eaxeJumpCtr;
    byte delayCtr;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -