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

📄 fighter.java

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

                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, 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, 0, 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, 0, 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, 1 | 2);
                        break;
                    }
                    g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                    break;
                }
    }

    public void drawStand(Graphics g)
    {
        if(!isWeapon)
        {
            switch(face)
            {
            case 26: // '\032'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 120, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
                break;

            case 27: // '\033'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawRegion(game.playerIm, 120, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
        } else
        {
            switch(Armor[ArmorCount])
            {
            default:
                break;

            case 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, 256, 0, 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) - 256, (y - 36) + game.axeIm.getHeight() / 2, 1 | 2);
                    break;
                }
                g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                break;

            case 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, 272, 0, 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) - 272, (y - 32) + game.chainIm.getHeight() / 2, 1 | 2);
                    break;
                }
                g.setClip(0, 0, game.WIDTH, game.HEIGHT);
                break;
            }
        }
    }

    public void drawJump(Graphics g)
    {
        switch(face)
        {
        case 26: // '\032'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 180, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
            break;

        case 27: // '\033'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawRegion(game.playerIm, 120, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
            break;
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

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

        case 26: // '\032'
            switch(fr)
            {
            case 0: // '\0'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 240, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
                break;

            case 1: // '\001'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 300, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;

        case 27: // '\033'
            switch(fr)
            {
            case 0: // '\0'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawRegion(game.playerIm, 240, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
                break;

            case 1: // '\001'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawRegion(game.playerIm, 300, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

    public void crouchAttack(Graphics g)
    {
        switch(face)
        {
        case 26: // '\032'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 360, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
            break;

        case 27: // '\033'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawRegion(game.playerIm, 360, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
            break;
        }
        weapon = 35;
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

    public void Attack(Graphics g)
    {
        switch(face)
        {
        case 26: // '\032'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 180, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
            break;

        case 27: // '\033'
            g.setClip((x - 30) + game.x1, y - 30, 60, 60);
            g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
            g.drawRegion(game.playerIm, 180, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
            break;
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

    public void drawWalk(Graphics g)
    {
        switch(fr)
        {
        default:
            break;

        case 0: // '\0'
            switch(face)
            {
            case 26: // '\032'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
                break;

            case 27: // '\033'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawRegion(game.playerIm, 0, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;

        case 1: // '\001'
            switch(face)
            {
            case 26: // '\032'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawImage(game.playerIm, (x + game.x1 + game.playerIm.getWidth() / 2) - 30 - 60, (y + game.playerIm.getHeight() / 2) - 30, 1 | 2);
                break;

            case 27: // '\033'
                g.setClip((x - 30) + game.x1, y - 30, 60, 60);
                g.clipRect((x - 30) + game.x1, y - 30, 60, 60);
                g.drawRegion(game.playerIm, 60, 0, 60, 60, 2, (x - 30) + game.x1, y - 30, 0x10 | 4);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;
        }
    }

    public void attackedAnimation(Graphics g)
    {
        int i = y - 10;
        if(hit)
        {
            g.setClip((x - 11) + game.x1, i - 9, 22, 19);
            g.clipRect((x - 11) + game.x1, i - 9, 22, 19);
            g.drawImage(game.fighterHit, ((x + game.x1) - 11) + game.fighterHit.getWidth() / 2, (i - 9) + game.fighterHit.getHeight() / 2, 1 | 2);
        }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
    }

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

        case 26: // '\032'
            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.drawRegion(game.dieIm, 112, 0, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                fr++;
                y++;
                break;

            case 1: // '\001'
                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, 0, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                fr++;
                y += 3;
                break;

            case 2: // '\002'
                y = 190;
                g.setClip((x - 28) + game.x1, y - 24, 56, 48);
                g.clipRect((x - 28) + game.x1, y - 24, 56, 48);
                g.drawRegion(game.dieIm, 0, 0, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;

        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, 1 | 2);
                fr++;
                y++;
                break;

            case 1: // '\001'
                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, 1 | 2);
                fr++;
                y++;
                break;

            case 2: // '\002'
                y = 190;
                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, (y + game.dieIm.getHeight() / 2) - 24, 1 | 2);
                break;
            }
            g.setClip(0, 0, game.WIDTH, game.HEIGHT);
            break;
        }
    }

    public void drawHitted(Graphics g)
    {
        if(hit)
            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, 0, 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, 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, 0, 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, 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, 0, 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, 1 | 2);
                    break;
                }
        g.setClip(0, 0, game.WIDTH, game.HEIGHT);
        if(System.currentTimeMillis() % 3L == 0L)
            hit = false;
    }

    public void drawFall(Graphics g)
    {
        if(hit && backAttack)
label0:
            switch(face)
            {
            default:
                break;

            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, 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, 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, 1 | 2);
                    if(System.currentTimeMillis() % 5L == 0L)
                    {
                        fr = 0;
                        backAttack = false;
                        hit = 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, 0, 56, 48, 2, (x - 28) + game.x1, y - 24, 0x10 | 4);

⌨️ 快捷键说明

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