用NetBeans开发J2ME游戏实例讲解(三)[4]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

            this.currentCursor[0] -= 1;//向左调

            this.currentCursor[1] -= 1;//向上调

        }


        if (this.currentCursor[0] + 1 < Images.WIDTH) {

            this.currentCursor[2] = this.MyMap.Grid[this.currentCursor[1]][this.currentCursor[0] + 1] != (byte) '1' ?

            (byte)1 : (byte)2;//是横向么?

        }else {

            this.currentCursor[2] = 1;

        }

        //设置光标的高度

        if (this.currentCursor[1] + 1 < Images.HEIGHT) {

            this.currentCursor[3] = this.MyMap.Grid[this.currentCursor[1] + 1][this.currentCursor[0]] != (byte) '2' ?

            (byte)1 : (byte)2;//是纵向么?

        }else {

            this.currentCursor[3] = 1;

        }

    }


    private boolean setMoveRange() {

        //设置要移动到的区域,能够移动返回true,否则返回false

        for (int i = 0; i < this.nextCursor[2]; i++) {

            for (int j = 0; j < this.nextCursor[3]; j++) {

                if (this.nextCursor[1] + j >= Images.HEIGHT ||

                    this.nextCursor[0] + i >= Images.WIDTH ||

                    (!isInRange(this.nextCursor[0] + i, this.nextCursor[1] + j) &&

                    this.MyMap.Grid[this.nextCursor[1] + j][this.nextCursor[0] + i] !=

                    Images.BLANK)) {

                return false;

                }

            }

        }

        return true;

    }


    private boolean isInRange(int x, int y) {

        //判断给定的(x,y)点是否在选定区域之内,x是水平坐标,y是竖直坐标

        if (x >= this.currentCursor[0] &&

            x < this.currentCursor[0] + this.currentCursor[2] &&

            y >= this.currentCursor[1] &&

            y < this.currentCursor[1] + this.currentCursor[3]) {

            return true;

        }else {

            return false;

        }

    }


    private boolean isInRange2(int x, int y) {

        //判断给定的(x,y)点是否在要移动到的区域之内,x是水平坐标,y是竖直坐标

        if (x >= this.nextCursor[0] &&

            x <  this.nextCursor[0] + this.nextCursor[2] &&

            y >= this.nextCursor[1] &&

            y <  this.nextCursor[1] + this.nextCursor[3]) {

            return true;

        }else {

            return false;

本文关键:用NetBeans开发J2ME游戏实例讲解(三)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top