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

📄 gamemanager.java

📁 基于j2me的手机赛车游戏源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// FrontEnd Plus GUI for JAD
// DeCompiled : GameManager.class

import com.nokia.mid.ui.DirectGraphics;
import com.nokia.mid.ui.DirectUtils;
import java.io.IOException;
import java.util.Random;
import javax.microedition.lcdui.*;

class GameManager
    implements Runnable
{

    boolean gC;
    Selezione se;
    boolean isSe;
    boolean isCa;
    boolean isCD;
    boolean isAv;
    boolean isViG;
    boolean isViA;
    boolean isGO;
    int iAu;
    int iAuAv;
    int cD;
    String tS;
    final int veM[] = {
        310, 305, 330, 350
    };
    final int tuM[] = {
        80, 80, 80, 30
    };
    final int cAu[] = {
        0xd680d6, 0xdf473f, 0xb14d6d, 0xffffff
    };
    final String nAu[] = {
        "honda", "mazda", "mitsubishi", "nissan"
    };
    int sT;
    int li;
    final Font fo = Font.getFont(0, 1, 0);
    Image sf;
    Image ni;
    Image fd;
    Image auG[];
    short dxA;
    short dyA;
    short an;
    int flip[] = {
        0, 90, 180, 270
    };
    int xSf256;
    int xSf;
    int r2562[];
    int liS[];
    int iniS[];
    int dxS[];
    int dxL[];
    boolean str[][];
    int poSt;
    int poSt256;
    int fr;
    int cu;
    int cu256;
    int po;
    int duSe;
    int n;
    boolean stTi;
    int crv[] = {
        0x102fc, 0x104fa, 0x106f8, 0x108f6, 0x10af4, 0x10bf3, 0x10cf2, 0x10d71, 0x10df1, 0x10e70, 
        0x10ef0, 0x10f6f, 0x10fef, 0x1106e, 0x110ee, 0x1116d, 0x111ed, 0x1126c, 0x112ec, 0x1136b
    };
    int strd[][] = {
        {
            0, 0, 3, 0, -2, 0, 2, -3, 0
        }, {
            0, -5, 7, 0, 0, -7, 8, 8, 0
        }, {
            0, 12, -12, 0, -12, 12, 0, -12, 12
        }
    };
    int ve256;
    int ve;
    int tur;
    short iAG;
    short xAG;
    short st256;
    int veT;
    int ca;
    int MeT[] = {
        15000, 20000, 25000
    };
    int mA256;
    int mA;
    short da;
    long tIn;
    boolean pAc;
    boolean pDc;
    boolean pDe;
    boolean pSi;
    boolean pTu;
    Immagine iSe;
    Immagine iLa;
    Immagine iTa;
    Immagine iFu;
    Immagine iAv;
    Immagine iAr;
    Arredo ar[];
    Ostacolo os[];
    Avversario av;
    int pi[][];
    final FastFuriousMIDlet mi;
    final Canvas can;
    Random ra;
    private boolean hBS;
    private volatile boolean iP;
    private volatile Thread aT;
    static final int MPT = 40;
    int vo;

    GameManager(FastFuriousMIDlet mi, Canvas can)
    {
        gC = false;
        cD = 3000;
        tS = "0.00.00";
        an = 20;
        xSf256 = 0;
        xSf = 0;
        poSt = 0;
        poSt256 = 0;
        fr = 0;
        po = 0;
        duSe = 256;
        stTi = false;
        ve256 = 0;
        ve = 0;
        iAG = 0;
        st256 = 0;
        veT = 200;
        ca = 0x271000;
        mA256 = 0;
        da = 100;
        pAc = false;
        pDc = false;
        pDe = false;
        pSi = false;
        pTu = false;
        hBS = false;
        iP = false;
        aT = null;
        vo = 0;
        this.mi = mi;
        this.can = can;
        se = new Selezione(mi);
        isSe = true;
        isCa = false;
        ra = new Random();
    }

    public void paint(Graphics g)
    {
        g.setClip(0, 0, 176, 208);
        DirectGraphics dg = DirectUtils.getDirectGraphics(g);
        try
        {
            if(isSe)
            {
                se.disegna(g);
                return;
            }
            if(isCa)
                return;
            g.setClip(0, 0, 176, 170);
            g.setColor(100, 90, 90);
            g.fillRect(0, 94, 176, 170);
            g.drawImage(sf, xSf, 0, an);
            g.drawImage(sf, xSf - 528, 0, an);
        }
        catch(Exception e) { }
        try
        {
            int segno = 1;
            if(cu < 0)
                segno = -1;
            int r = crv[segno * cu];
            int cc = 255;
            int errore = 0;
            g.setColor(255, 255, 255);
            for(this.n = 75; this.n > 0; this.n--)
            {
                if(ve > 10 && isAv && !iP)
                    errore = ra.nextInt() & 0x1;
                cc *= r;
                cc >>= 16;
                int cci = (segno * (cc >> 8) + 1) - (1 + segno) / 2;
                liS[this.n] = iniS[this.n] + cci;
                g.setColor(50, 50, 50);
                g.drawLine((liS[this.n] - dxL[this.n] / 2) + errore, 94 + this.n, liS[this.n] + 2 * dxS[this.n] + 2 + dxL[this.n] / 2 + errore, 94 + this.n);
                g.setColor(255, 255, 255);
                g.drawLine((liS[this.n] - dxL[this.n] / 2) + errore, 94 + this.n, liS[this.n] + 1 + dxL[this.n] / 2 + errore, 94 + this.n);
                if(str[poSt][this.n])
                    g.drawLine((liS[this.n] + dxS[this.n]) - dxL[this.n] / 2, 94 + this.n, liS[this.n] + dxS[this.n] + dxL[this.n] / 2, 94 + this.n);
                g.drawLine(((liS[this.n] + 2 * dxS[this.n] + 1) - dxL[this.n] / 2) + errore, 94 + this.n, liS[this.n] + 2 * dxS[this.n] + 2 + dxL[this.n] / 2 + errore, 94 + this.n);
            }

        }
        catch(Exception e) { }
        try
        {
            for(int n = 0; n < 2; n++)
                ar[n].di(dg);

        }
        catch(Exception e) { }
        try
        {
            for(int n = 0; n < 4; n++)
            {
                pi[n][0] = os[n].pi();
                pi[n][1] = n;
            }

            pi[4][0] = av.pi();
            pi[4][1] = 4;
            pi[5][0] = 0;
            pi[5][1] = 5;
            qS(pi, 6);
            for(int n = 0; n < 6; n++)
                if(pi[n][1] < 4)
                    os[pi[n][1]].di(dg);
                else
                if(pi[n][1] == 4)
                    av.di(dg, g);
                else
                    diGi(dg);

            diAr(dg);
            g.setClip(0, 0, 176, 208);
            g.setColor(42, 68, 93);
            g.fillRect(0, 170, 176, 208);
            g.drawImage(fd, 60, 176, an);
            g.setColor(47, 93, 186);
            g.fillRect(6, 179, ((ca >> 8) * 50) / 10000, 8);
            g.setColor(248, 94, 3);
            g.fillRect(6, 190, ((100 - da) * 50) / 100, 8);
            g.setColor(113, 125, 136);
            g.fillRect(121, 179, ((av.ca >> 8) * 50) / 10000, 8);
            g.fillRect(121, 190, ((100 - av.da) * 50) / 100, 8);
            g.setColor(0, 0, 0);
            g.drawRoundRect(5, 178, 51, 9, 5, 5);
            g.drawRoundRect(5, 190, 51, 9, 5, 5);
            g.drawRoundRect(120, 178, 51, 9, 5, 5);
            g.drawRoundRect(120, 190, 51, 9, 5, 5);
            g.setColor(255, 0, 0);
            if(tur > 0)
                g.fillRoundRect(61, 178, 7, 7, 5, 5);
            if(av.tu > 0)
                g.fillRoundRect(109, 178, 7, 7, 5, 5);
            g.setFont(fo);
            g.setColor(0, 0, 0);
            g.drawString("" + ve, 134 - fo.stringWidth("" + ve), 7, an);
            g.drawString("Km/h", 136, 7, an);
            g.drawString(tS, 7, 7, an);
            g.setColor(255, 204, 0);
            g.drawString("" + ve, 133 - fo.stringWidth("" + ve), 6, an);
            g.drawString("Km/h", 135, 6, an);
            g.drawString(tS, 6, 6, an);
            g.setColor(200, 200, 200);
            g.fillRect(5, 27, 164, 3);
            g.setColor(cAu[iAu]);
            g.fillRect(5 + ((mA256 >> 8) * 164) / MeT[li], 22, 5, 3);
            g.setColor(cAu[iAuAv]);
            g.fillRect(5 + ((av.me256 >> 8) * 164) / MeT[li], 32, 5, 3);
            if(isCD)
                if(cD > 1)
                    mi.te.sc(1, "" + (cD / 1000 + 1), g, 82, 70);
                else
                    mi.te.sc(1, "start", g, 52, 70);
            if(isViG)
            {
                mi.te.sc(1, nAu[iAu], g, 19, 70);
                mi.te.sc(1, "vince", g, 89, 87);
            } else
            if(isViA)
            {
                mi.te.sc(1, nAu[iAuAv], g, 19, 70);
                mi.te.sc(1, "vince", g, 89, 87);
            }
        }
        catch(Exception e) { }
    }

    private void diGi(DirectGraphics dg)
    {
        int rf = fr;
        short d = 8192;
        if(fr < 0)
        {
            d = 0;
            rf *= -1;
        }
        dg.drawImage(auG[rf], xAG - dxA / 2, 170 - dyA, an, d);
        if(tur > 0 && !iP)
            if(iAu == 0)
            {
                dg.drawImage(ni, xAG - 14 - fr * 2, 162, an, flip[ra.nextInt() & 0x3]);
                dg.drawImage(ni, (xAG + 6) - fr * 2, 162, an, flip[ra.nextInt() & 0x3]);
            } else
            {
                dg.drawImage(ni, xAG - 4 - fr * 2, 162, an, flip[ra.nextInt() & 0x3]);
            }
    }

    private void tick()
    {
        if(isSe)
            se.tick();
        else
        if(!isCa)
        {
            if(isCD)
            {
                cD -= 40;
                if(cD <= 0)
                {
                    isAv = true;
                    tIn = System.currentTimeMillis();
                }
                if(cD < -2000)
                    isCD = false;
            }
            if(isAv)
            {
                if(pAc && ve < veM[iAu] - sT)
                    ve256 += 320;
                else
                if(pDc && ve > 0)
                {
                    ve256 -= 512;
                    tur = 0;
                }
                if(pDe)
                    st256 += 128;
                if(pSi)
                    st256 -= 128;
                if(pTu && tur == 0 && ve > 120)
                {
                    veT = ve;
                    tur = 300;
                    pTu = false;
                }
                if(st256 > 2048)
                    st256 = 2048;
                if(st256 < -2048)
                    st256 = -2048;
                ve = ve256 >> 8;
                if(cu < strd[li][po])
                    cu256 += (ve / 2 + 16) - ve / 16;
                else
                if(cu > strd[li][po])
                    cu256 -= (ve / 2 + 16) - ve / 16;
                duSe--;
                if(duSe < 0 && ve > 0)
                {
                    duSe = 384 - ve;
                    po++;
                    if(po == 9)
                        po = 0;
                }
                cu = cu256 >> 8;
                if(cu < -19)
                    cu = -19;
                if(cu > 19)
                    cu = 19;
                for(xSf256 -= cu * ve >> 3; xSf256 < 0; xSf256 += 0x21000);
                for(; xSf256 > 0x18000; xSf256 -= 0x21000);
                xSf = xSf256 >> 8;
                poSt256 += ve * 5;
                poSt = poSt256 >> 8;
                if(poSt >= 20)
                {
                    poSt = 0;
                    poSt256 = 0;
                }
                ve = ve256 >> 8;
                xAG -= cu * ve >> 10;
                xAG += (120 * (st256 * ve >> 16)) / 100;
                if(st256 > 0)
                    st256 -= 32;
                if(st256 < 0)
                    st256 += 32;
                fr = st256 >> 9;
                if(fr > 2)
                    fr = 2;
                if(fr < -2)
                    fr = -2;
                if(xAG <= 0)
                {
                    xAG = 0;
                    ve256 -= 64 * li;
                }
                if(xAG >= 176)
                {
                    xAG = 176;
                    ve256 -= 64 * li;
                }
                if(ve256 < 0)
                    ve256 = 0;
                ve = ve256 >> 8;
                if(ve > 0)
                {
                    ca -= ve;
                    if(tur > 0)
                        ca -= 3 * ve;
                }
                if(ca < 0)
                {
                    ve256 = 0;
                    ve = ve256 >> 8;
                    vAvv();
                    isGO = true;
                    isAv = false;
                }
                if(tur > 0)
                {
                    tur--;
                    if(tur > 300 - (veM[iAu] - veT))
                        ve256 += 768;
                    if(ve > veM[iAu])
                        ve256 = veM[iAu] << 8;
                } else
                if(tur == 0 && ve > veT)
                    ve256 -= 256;
                ve = ve256 >> 8;
                if(veT == ve)
                    veT = veM[iAu] - sT;

⌨️ 快捷键说明

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