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

📄 scroller.java

📁 java程序源代码很好的东西啊,好的不的了啊,大家要下啊
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 

import java.io.*;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

// Referenced classes of package game:
//            GameScreen

public class Scroller
{

    Image ITiles;
    private static final int _$372 = 40;
    private static final int _$369 = 350;
    private static final int _$380 = 7;
    int PIXELHEIGHT;
    int PIXELWIDTH;
    byte b[];
    private static final boolean _$381[] = {
        false, false, false, false, false, false, false
    };
    public int iMapLoaded;
    int iMapTileHe;
    int iMapTileWi;
    int iMapXPixPos;
    int iMapYPixPos;
    public int iNofLayer1;
    int iScrollHe;
    int iScrollWi;
    int iTileHe;
    private int _$401;
    int iTileSize;
    int iTileWi;
    int iTilesTileHe;
    int iTilesTileWi;
    InputStream is;
    public char map[][];
    int mapXTilePos;
    int mapYTilePos;
    public short sLayer1[];

    public Scroller(int i, int j, int k, GameScreen gamescreen)
    {
        sLayer1 = new short[350];
        iTilesTileWi = 1;
        iTilesTileHe = 1;
        _$401 = -1;
        b = new byte[40];
        iMapLoaded = -1;
        gamescreen.drawLoading(30);
        PIXELWIDTH = i;
        PIXELHEIGHT = j;
        iTileSize = k;
        iScrollWi = (i - 1) / k + 2;
        iScrollWi *= k;
        iScrollHe = (j - 1) / k + 2;
        iScrollHe *= k;
        iTileWi = iScrollWi / k;
        iTileHe = iScrollHe / k;
        gamescreen.drawLoading(35);
        gamescreen.drawLoading(40);
        gamescreen.drawLoading(45);
        map = new char[40][40];
        gamescreen.drawLoading(50);
        gamescreen.drawLoading(55);
    }

    short b2toS(byte byte0, byte byte1)
    {
        int i = 0;
        if(byte0 < 0)
            i = 256 + byte0;
        else
            i = byte0;
        i += byte1 << 8;
        return (short)i;
    }

    void down(int i)
    {
        iMapYPixPos += i;
        if(iMapYPixPos >= iMapTileHe * iTileSize - PIXELHEIGHT)
            iMapYPixPos = iMapTileHe * iTileSize - 1 - PIXELHEIGHT;
    }

    void left(int i)
    {
        iMapXPixPos -= i;
        if(iMapXPixPos < 0)
            iMapXPixPos = 0;
    }

    void loadMap(int i)
    {
        if(iMapLoaded == i)
            return;
        iMapLoaded = i;
        String s = "/level/clu1.clu";
        if(i >= 8 && i <= 30)
            s = "/level/clu2.clu";
        if(i > 30)
            s = "/level/clu3.clu";
        is = getClass().getResourceAsStream(s);
        try
        {
            is.read(b, 0, 2);
            short word0 = b2toS(b[1], b[0]);
            is.read(b, 0, word0 * 2);
            int j1 = 1;
            if(i <= 6)
                j1 = i - 1;
            if(i == 8)
                j1 = 0;
            if(i == 12)
                j1 = 1;
            if(i == 14)
                j1 = 2;
            if(i == 18)
                j1 = 3;
            if(i == 22)
                j1 = 4;
            if(i == 26)
                j1 = 5;
            if(i == 30)
                j1 = 6;
            if(i > 30)
                j1 = i - 31;
            int k1 = 0;
            for(int l1 = 0; l1 < j1; l1++)
                k1 += b2toS(b[l1 * 2 + 1], b[l1 * 2]);

            is.skip(k1);
            is.read(b, 0, 4);
            iMapTileWi = b[0];
            iMapTileHe = b[2];
            for(int l = 0; l < iMapTileHe; l++)
            {
                is.read(b, 0, iMapTileWi);
                int i1 = 0;
                for(int k = 0; k < iMapTileWi; k++)
                    map[k][l] = (char)b2toS(b[i1++], (byte)0);

            }

            is.read(b, 0, 2);
            short word1 = b2toS(b[1], b[0]);
            iNofLayer1 = 0;
            for(int j = 0; j < word1; j++)
            {
                is.read(b, 0, 3);
                sLayer1[iNofLayer1++] = b2toS(b[0], (byte)0);
                sLayer1[iNofLayer1++] = b2toS(b[1], (byte)0);
                int i2 = b2toS(b[2], (byte)0) - 17;
                sLayer1[iNofLayer1++] = (short)i2;
            }

        }
        catch(IOException ioexception) { }
        iNofLayer1 /= 3;
    }

    void loadTileSet(int i)
    {
        if(_$401 == i)
            return;
        _$401 = i;
        ITiles = null;
        System.gc();
        try
        {
            ITiles = Image.createImage("/gfx/tileset" + _$401 + ".png");
        }
        catch(Exception exception)
        {
            System.out.println("LoadTiles Exception: " + exception);
        }
        iTilesTileWi = ITiles.getWidth() / iTileSize;
        iTilesTileHe = ITiles.getHeight() / iTileSize;
    }

    void paint(Graphics g, int i, int j)
    {
        int k2 = iMapXPixPos % iTileSize;
        int l2 = iMapYPixPos % iTileSize;
        for(int l = 0; l < iScrollHe / iTileSize; l++)
        {
            for(int k = 0; k < iScrollWi / iTileSize; k++)
            {
                int i1 = i + k * iTileSize;
                int j1 = j + l * iTileSize;
                int k1 = iTileSize;
                int l1 = iTileSize;
                char c = map[iMapXPixPos / iTileSize + k][iMapYPixPos / iTileSize + l];
                int i2 = (c & 0x3) * iTileSize;
                int j2 = (c >> 2) * iTileSize;
                g.setClip(i1 - k2, j1 - l2, k1, l1);
                g.drawImage(ITiles, i1 - i2 - k2, j1 - j2 - l2, 0);
            }

        }

    }

    void right(int i)
    {
        iMapXPixPos += i;
        if(iMapXPixPos >= iMapTileWi * iTileSize - PIXELWIDTH)
            iMapXPixPos = iMapTileWi * iTileSize - 1 - PIXELWIDTH;
    }

    void setScrollerPos(int i, int j)
    {
        iMapXPixPos = i;
        iMapYPixPos = j;
    }

    void up(int i)
    {
        iMapYPixPos -= i;
        if(iMapYPixPos < 0)
            iMapYPixPos = 0;
    }

}

⌨️ 快捷键说明

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