Block.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace Snake_s
{
class Block
{
private Color _color; //颜色
private int _size; //单位大小
private Point _point; //具体坐标
public Point Point
{
get { return _point; }
//set { _point = value; }
}
// 下载于www.51aspx.com
//构造block函数
public Block(Color color, int size, Point point)
{
this._color = color;
this._size = size;
this._point = point;
}
//将自身绘制到画布上
public void Paint(Graphics g)
{
SolidBrush sb = new SolidBrush(_color);
lock (g)
{
try
{
//将定义的“蛇块”设置为笔刷填充到制定矩形区域当中
g.FillRectangle
(
sb,
this.Point.X * this._size,
this.Point.Y * this._size,
this._size - 1,
this._size - 1
);
//绘制的大小比size小1个像素,这么做的原因是为了突出蛇块与蛇块之间的间隙,也就是说蛇块与蛇块之间有1个像素的间隙
}
catch
{ }
}
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。