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

📄 item.java

📁 java 小程序 使用j2me 开发的一个小的游戏软件
💻 JAVA
字号:
import javax.microedition.lcdui.*;

public class Item
{
    public int x,y,type,status;
    private boolean isdraw;
    private int displaycount = 1;
    //元素坐标,序号:33,34,78,35,73,74
    //原图起始坐标X,坐标Y,宽,高,所在图片编号
    public static int[][] itemdetail={
        {0,0,8,8,7},{0,0,8,8,7},{0,0,29,30,11},{0,0,11,9,12},
        {0,0,15,14,13},{0,0,15,15,14}
    };

    public Item(int startx,int starty,int itemtype,int itemstatus)
    {
        x = startx;
        y = starty;
        type = itemtype;
        status = itemstatus;
    }

    public void paint(Graphics g)
    {
        isdraw = false;

        if(TomAdventureCanvas.mapx<=x && x<=TomAdventureCanvas.mapx+TomAdventureCanvas.vieww
            && TomAdventureCanvas.mapy<=y && y<=TomAdventureCanvas.mapy+TomAdventureCanvas.viewh)
        {
            isdraw = true;
        }
        else if(TomAdventureCanvas.mapx<=x+itemdetail[type][2] && x+itemdetail[type][2]<=TomAdventureCanvas.mapx+TomAdventureCanvas.vieww
            && TomAdventureCanvas.mapy<=y && y<=TomAdventureCanvas.mapy+TomAdventureCanvas.viewh)
        {
            isdraw = true;
        }
        else if(TomAdventureCanvas.mapx<=x && x<=TomAdventureCanvas.mapx+TomAdventureCanvas.vieww
            && TomAdventureCanvas.mapy<=y+itemdetail[type][3] && y+itemdetail[type][3]<=TomAdventureCanvas.mapy+TomAdventureCanvas.viewh)
        {
            isdraw = true;
        }
        else if(TomAdventureCanvas.mapx<=x+itemdetail[type][2] && x+itemdetail[type][2]<=TomAdventureCanvas.mapx+TomAdventureCanvas.vieww
            && TomAdventureCanvas.mapy<=y+itemdetail[type][3] && y+itemdetail[type][3]<=TomAdventureCanvas.mapy+TomAdventureCanvas.viewh)
        {
            isdraw = true;
        }

        switch(status)
        {
            case 0:
                if(isdraw == true)
                {
                    isdraw = false;
                }
                break;
            case 1:
                break;
            case 2:
                if(displaycount>=1 && displaycount<=2)
                {

                }
                else if(displaycount>=3 && displaycount<=4)
                {
                    if(isdraw == true)
                    {
                        isdraw = false;
                    }
                }
                else
                {
                    displaycount = 0;
                }
                displaycount++;
                break;
        }


        if(isdraw == true)
        {
            //System.out.println(type);
            //System.out.println(itemdetail[type][4]);
            TomAdventureCanvas.drawClipImage(g,x-TomAdventureCanvas.mapx,y-TomAdventureCanvas.mapy,TomAdventureCanvas.imgitem[itemdetail[type][4]],itemdetail[type][0],itemdetail[type][1],itemdetail[type][2],itemdetail[type][3]);
        }
    }
}

⌨️ 快捷键说明

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