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

📄 gamecanvas.java

📁 j2me游戏代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            {
                int l = random.nextInt() % (nWindow * nWindow);
                if(l < 0)
                    l = -l;
                if(!bAKiller[l / nWindow][l % nWindow])
                {
                    int j = l;
                    k++;
                    bAKiller[j / nWindow][j % nWindow] = true;
                }
            }

        }
    }

    private void setOneKiller()
    {
        bAKiller[nX][nY] = false;
        int i;
        do
        {
            i = random.nextInt() % (nWindow * nWindow);
            if(i < 0)
                i = -i;
        } while(bAKiller[i / nWindow][i % nWindow] || bAMap[i / nWindow][i % nWindow]);
        bAKiller[i / nWindow][i % nWindow] = true;
    }

    private void drawTarget()
    {
        int i = 0;
        gx.setColor(0);
        gx.drawLine(23, 56, 55, 56);
        gx.drawLine(64, 15, 64, 48);
        gx.drawLine(73, 56, 105, 56);
        gx.drawLine(64, 66, 64, 97);
        if(nX == 0)
        {
            GameCanvas _tmp = this;
            GameCanvas _tmp1 = this;
            GameCanvas _tmp2 = this;
            dg.drawImage(gameMain.gameImg.arrow_2, 14, 52, 0x4 | 0x10, 180);
            GameCanvas _tmp3 = this;
            GameCanvas _tmp4 = this;
            gx.drawImage(gameMain.gameImg.no[0], 34, 52, 0x4 | 0x10);
        } else
        {
            GameCanvas _tmp5 = this;
            GameCanvas _tmp6 = this;
            GameCanvas _tmp7 = this;
            dg.drawImage(gameMain.gameImg.arrow_1, 14, 52, 0x4 | 0x10, 180);
            for(int j = 0; j < nWindow; j++)
            {
                for(int j1 = 0; j1 < nX; j1++)
                    if(bAKiller[j1][j])
                        i++;

            }

            GameCanvas _tmp8 = this;
            GameCanvas _tmp9 = this;
            gx.drawImage(gameMain.gameImg.no[i], 34, 52, 0x4 | 0x10);
            i = 0;
        }
        if(nX == nWindow - 1)
        {
            GameCanvas _tmp10 = this;
            GameCanvas _tmp11 = this;
            gx.drawImage(gameMain.gameImg.arrow_2, 106, 51, 0x4 | 0x10);
            GameCanvas _tmp12 = this;
            GameCanvas _tmp13 = this;
            gx.drawImage(gameMain.gameImg.no[0], 96, 52, 0x4 | 0x10);
        } else
        {
            GameCanvas _tmp14 = this;
            GameCanvas _tmp15 = this;
            gx.drawImage(gameMain.gameImg.arrow_1, 106, 51, 0x4 | 0x10);
            for(int k = 0; k < nWindow; k++)
            {
                for(int k1 = nWindow - 1; k1 > nX; k1--)
                    if(bAKiller[k1][k])
                        i++;

            }

            GameCanvas _tmp16 = this;
            GameCanvas _tmp17 = this;
            gx.drawImage(gameMain.gameImg.no[i], 96, 52, 0x4 | 0x10);
            i = 0;
        }
        if(nY == 0)
        {
            GameCanvas _tmp18 = this;
            GameCanvas _tmp19 = this;
            GameCanvas _tmp20 = this;
            dg.drawImage(gameMain.gameImg.arrow_2, 60, 5, 0x4 | 0x10, 90);
            GameCanvas _tmp21 = this;
            GameCanvas _tmp22 = this;
            gx.drawImage(gameMain.gameImg.no[0], 65, 15, 0x4 | 0x10);
        } else
        {
            GameCanvas _tmp23 = this;
            GameCanvas _tmp24 = this;
            GameCanvas _tmp25 = this;
            dg.drawImage(gameMain.gameImg.arrow_1, 60, 5, 0x4 | 0x10, 90);
            for(int l = 0; l < nWindow; l++)
            {
                for(int l1 = 0; l1 < nY; l1++)
                    if(bAKiller[l][l1])
                        i++;

            }

            GameCanvas _tmp26 = this;
            GameCanvas _tmp27 = this;
            gx.drawImage(gameMain.gameImg.no[i], 65, 15, 0x4 | 0x10);
            i = 0;
        }
        if(nY == nWindow - 1)
        {
            GameCanvas _tmp28 = this;
            GameCanvas _tmp29 = this;
            GameCanvas _tmp30 = this;
            dg.drawImage(gameMain.gameImg.arrow_2, 61, 97, 0x4 | 0x10, 270);
            GameCanvas _tmp31 = this;
            GameCanvas _tmp32 = this;
            gx.drawImage(gameMain.gameImg.no[0], 65, 85, 0x4 | 0x10);
        } else
        {
            GameCanvas _tmp33 = this;
            GameCanvas _tmp34 = this;
            GameCanvas _tmp35 = this;
            dg.drawImage(gameMain.gameImg.arrow_1, 61, 97, 0x4 | 0x10, 270);
            for(int i1 = 0; i1 < nWindow; i1++)
            {
                for(int i2 = nWindow - 1; i2 > nY; i2--)
                    if(bAKiller[i1][i2])
                        i++;

            }

            GameCanvas _tmp36 = this;
            GameCanvas _tmp37 = this;
            gx.drawImage(gameMain.gameImg.no[i], 65, 85, 0x4 | 0x10);
        }
        GameCanvas _tmp38 = this;
        GameCanvas _tmp39 = this;
        gx.drawImage(gameMain.gameImg.no[0], 24, 52, 0x4 | 0x10);
        GameCanvas _tmp40 = this;
        GameCanvas _tmp41 = this;
        gx.drawImage(gameMain.gameImg.no[0], 86, 52, 0x4 | 0x10);
        GameCanvas _tmp42 = this;
        GameCanvas _tmp43 = this;
        gx.drawImage(gameMain.gameImg.no[0], 55, 15, 0x4 | 0x10);
        GameCanvas _tmp44 = this;
        GameCanvas _tmp45 = this;
        gx.drawImage(gameMain.gameImg.no[0], 55, 85, 0x4 | 0x10);
    }

    private void drawHole()
    {
        if(bAKiller[nX][nY])
        {
            bAKiller[nX][nY] = false;
            nKiller--;
            bTarget = false;
            GameCanvas _tmp = this;
            GameCanvas _tmp1 = this;
            gx.drawImage(gameMain.gameImg.hole, nTX, nTY, 0x1 | 0x2);
            gx.setColor(0, 0, 255);
            GameCanvas _tmp2 = this;
            GameCanvas _tmp3 = this;
            gx.drawString("Nice", 64, 50, 0x1 | 0x10);
            if(nChar == 0)
                nScore += 15;
            else
            if(nChar == 1)
                nScore += 20;
            else
            if(nChar == 2)
                nScore += 10;
            if(nKiller <= 0)
            {
                load3();
                nGame = GAME_SUC;
                gameEffects.eachSound(6);
            }
            nTY = 96;
            nTX = 23;
        } else
        {
            if(bBullet)
            {
                bBullet = false;
                GameCanvas _tmp4 = this;
                GameCanvas _tmp5 = this;
                gx.drawImage(gameMain.gameImg.hole, nTX, nTY, 0x1 | 0x2);
                nTY = 96;
                nTX = 23;
            } else
            {
                GameCanvas _tmp6 = this;
                GameCanvas _tmp7 = this;
                gx.drawImage(gameMain.gameImg.hole, nTX, nTY, 0x1 | 0x2);
                nGame = GAME_OVER;
                gameEffects.eachSound(8);
            }
            bTarget = false;
        }
        nShoot = 0;
    }

    private void drawEnd()
    {
        gx.setColor(153, 0, 0);
        gx.fillRect(0, 0, 128, 4);
        gx.fillRect(0, 86, 128, 31);
        gx.setColor(204, 102, 0);
        gx.fillRect(0, 4, 128, 16);
        gx.setColor(255, 102, 0);
        gx.fillRect(0, 19, 128, 33);
        gx.setColor(255, 153, 0);
        gx.fillRect(0, 52, 128, 15);
        gx.fillRect(0, 79, 128, 7);
        gx.setColor(255, 204, 0);
        gx.fillRect(0, 67, 128, 12);
        gx.setColor(98, 3, 3);
        gx.fillRect(0, 117, 128, 11);
        GameCanvas _tmp = this;
        GameCanvas _tmp1 = this;
        gx.drawImage(sun, 64, 16, 0x1 | 0x10);
        if(nGame == GAME_SUC)
        {
            GameCanvas _tmp2 = this;
            GameCanvas _tmp3 = this;
            gx.drawImage(shadow, 64, 30, 0x1 | 0x10);
            gx.setColor(0);
            GameCanvas _tmp4 = this;
            GameCanvas _tmp5 = this;
            gx.drawString("Mission", 64, 5, 0x1 | 0x10);
            GameCanvas _tmp6 = this;
            GameCanvas _tmp7 = this;
            gx.drawString("clear", 64, 15, 0x1 | 0x10);
        } else
        {
            GameCanvas _tmp8 = this;
            GameCanvas _tmp9 = this;
            gx.drawImage(tombstone, 64, 30, 0x1 | 0x10);
            gx.setColor(0);
            GameCanvas _tmp10 = this;
            GameCanvas _tmp11 = this;
            gx.drawString("You", 64, 5, 0x1 | 0x10);
            GameCanvas _tmp12 = this;
            GameCanvas _tmp13 = this;
            gx.drawString("failed", 64, 15, 0x1 | 0x10);
        }
    }

    public void drawClock()
    {
        GameCanvas _tmp = this;
        GameCanvas _tmp1 = this;
        gx.drawImage(gameMain.gameImg.no[nTime / 60], 47, 114, 0x4 | 0x10);
        GameCanvas _tmp2 = this;
        GameCanvas _tmp3 = this;
        gx.drawImage(gameMain.gameImg.num_0, 56, 116, 0x4 | 0x10);
        GameCanvas _tmp4 = this;
        GameCanvas _tmp5 = this;
        gx.drawImage(gameMain.gameImg.no[(nTime % 60) / 10], 58, 114, 0x4 | 0x10);
        GameCanvas _tmp6 = this;
        GameCanvas _tmp7 = this;
        gx.drawImage(gameMain.gameImg.no[nTime % 60 % 10], 67, 114, 0x4 | 0x10);
        GameCanvas _tmp8 = this;
        GameCanvas _tmp9 = this;
        gx.drawImage(gameMain.gameImg.no[0], 106, 114, 0x4 | 0x10);
        GameCanvas _tmp10 = this;
        GameCanvas _tmp11 = this;
        gx.drawImage(gameMain.gameImg.no[nKiller], 115, 114, 0x4 | 0x10);
    }

    private void drawMap()
    {
        gx.setColor(254, 255, 255);
        gx.drawLine(0, 79, 0, 110);
        gx.drawLine(0, 79, 30, 79);
        gx.setColor(128, 64, 128);
        gx.drawLine(31, 79, 31, 110);
        gx.drawLine(1, 110, 31, 110);
        gx.setColor(192, 160, 192);
        gx.drawRect(1, 80, 30, 30);
        gx.setColor(128, 192, 255);
        gx.fillRect(2, 81, 29, 29);
        if(nLevel == 0 || nLevel == 1)
        {
            for(int i = 0; i < 5; i++)
            {
                for(int l = 0; l < 5; l++)
                {
                    if(bAMap[i][l])
                        gx.setColor(255, 0, 0);
                    else
                        gx.setColor(0);
                    gx.fillRect(9 + i * 3, 88 + l * 3, 2, 2);
                }

            }

            gx.setColor(254, 255, 255);
            gx.fillRect(9 + nX * 3, 88 + nY * 3, 2, 2);
        } else
        if(nLevel == 2)
        {
            for(int j = 0; j < 7; j++)
            {
                for(int i1 = 0; i1 < 7; i1++)
                {
                    if(bAMap[j][i1])
                        gx.setColor(255, 0, 0);
                    else
                        gx.setColor(0);
                    gx.fillRect(6 + j * 3, 85 + i1 * 3, 2, 2);
                }

            }

            gx.setColor(254, 255, 255);
            gx.fillRect(6 + nX * 3, 85 + nY * 3, 2, 2);
        } else
        if(nLevel == 3)
        {
            for(int k = 0; k < 9; k++)
            {
                for(int j1 = 0; j1 < 9; j1++)
                {
                    if(bAMap[k][j1])
                        gx.setColor(255, 0, 0);
                    else
                        gx.setColor(0);
                    gx.fillRect(3 + k * 3, 82 + j1 * 3, 2, 2);
                }

            }

            gx.setColor(254, 255, 255);
            gx.fillRect(3 + nX * 3, 82 + nY * 3, 2, 2);
        }
    }

    public void load3()
    {
        try
        {
            shadow = Image.createImage("/img/shadow.png");
            sun = Image.createImage("/img/sun.png");
            tombstone = Image.createImage("/img/tombstone.png");
        }
        catch(IOException ioexception) { }
    }

}

⌨️ 快捷键说明

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