我看了已个俄罗斯方的代码,有点不懂。希望知道的高诉我一下什么意思
代码:
public const int width = 20; //场景的宽,以方块个数为单位
public const int height = 30;
public static int[] arrBitBlock=new int[height]; //位数组:当某个位置有方块时,该行的该位为1 public static bool isEmpty(int x, int y)
{
//先检测是否越界
if (y < 0 || y >= height)
return false;
if (x < 0 || x >= width)
return false;
//然后检测是否为空
if ((arrBitBlock[y] & (1 << x)) != 0)
return false;
else
return true;
}
public static int[] arrBitBlock=new int[height]; 这一句不是默认数组值不是都是0吗?
((arrBitBlock[y] & (1 << x)) 得到的不是应该是0吗?返回值应该都是true才对。
不怎么明白,它是怎么判断方块附近是否为空的,希望有人讲解下。
代码:
public const int width = 20; //场景的宽,以方块个数为单位
public const int height = 30;
public static int[] arrBitBlock=new int[height]; //位数组:当某个位置有方块时,该行的该位为1 public static bool isEmpty(int x, int y)
{
//先检测是否越界
if (y < 0 || y >= height)
return false;
if (x < 0 || x >= width)
return false;
//然后检测是否为空
if ((arrBitBlock[y] & (1 << x)) != 0)
return false;
else
return true;
}
public static int[] arrBitBlock=new int[height]; 这一句不是默认数组值不是都是0吗?
((arrBitBlock[y] & (1 << x)) 得到的不是应该是0吗?返回值应该都是true才对。
不怎么明白,它是怎么判断方块附近是否为空的,希望有人讲解下。
解决方案 »
- 如何刷新文件夹?
- 打印机问题~请各位帮忙
- 【200分】紧急求助高手,为何Remoting不能正常连接?
- 控件
- WinForm窗体界面问题
- 巨大的问题-----PostMessage为什么没有反映呢 ?发信息错误吗 ?
- 再问一次呀同志们:如何绑定数据
- 用Grid++Report 4.5做报表时,“Report.Parameters["YSJE"]”引发了“System.Runtime.InteropServices.COMException”类型的异常?
- 新手提问~!各位大侠行行好~~!!!!
- C#的TCPClient怎样获取接收到的数据长度?
- C# 怎么获取类或者接口的GUID
- c# winform datagridview
----------------
都是0((arrBitBlock[y] & (1 < < x))
--------------
1<<x就是1向左移x位 就是2^x次方 ,就是左边第x位是,其余是0
&运算 同1则1